8

I did a fresh install of Ubuntu 20.04 today. I got as far as setting up my vim environment which installs plug.vim using curl when I hit a speed bump.

Error creating directory /home/simon/.vim/autoload.
curl: (23) Failed writing received data to disk/application

The relevant lines in the .vimrc are:

" Auto-install plugin manager if it doesnt exist (and PlugInstall)
if empty(glob('~/.vim/autoload/plug.vim'))
    silent !curl -fLo ~/.vim/autoload/plug.vim --create-dirs
        \ https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
    autocmd VimEnter * PlugInstall | source $MYVIMRC
endif

Trying to isolate the problem, it seems like I can't use a path with a dot file in it as an output for curl.

eg. This fails:

➜  ~ curl -fLo ~/.test_dot_folder/test.py --create-dirs example.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0Warning: Failed to create the file /home/simon/.test_dot_folder/test.py: No 
Warning: such file or directory
100  1256  100  1256    0     0   2800      0 --:--:-- --:--:-- --:--:--  2803
curl: (23) Failure writing output to destination

But this works:

➜  ~ curl -fLo ~/test_dot_folder/test.py --create-dirs example.com
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  1256  100  1256    0     0   2659      0 --:--:-- --:--:-- --:--:--  2661
➜  ~ 

The only difference is the . in front of the folder. Even when I do

mkdir .test_dot_folder

and then run the first curl command, it still fails.

If you're wondering about permissions in the directory:

Here's what happens when I run @waltinator's pathlld script on my home directory.

➜  ~ sudo code/pathlld.sh -v . 

drwxr-xr-x 22 simon simon 4096 Aug  7 20:15 . 
/dev/nvme0n1p5 on / type ext4 (rw,relatime,errors=remount-ro)

Any suggestions as to what's going wrong?

Teg Veece
  • 81
  • 1
  • 3
  • Explore your permission/ownership problems with `https://github.com/waltinator/pathlld`. A `bash` script to answer "Why can't I Read/Write that file?". – waltinator Aug 06 '21 at 18:13
  • Thanks @waltinator. I've downloaded the script but it's unclear what I should be providing as input to it. The curl command fails when creating a file beginning with a `.` in my home directory which I seem to have all of the relevant permissions for: ➜ /home ./simon/code/pathlld.sh simon drwxr-xr-x 22 simon simon 4096 Aug 7 05:49 simon – Teg Veece Aug 06 '21 at 19:52
  • Type `sudo /path/to/pathlld.sh /path/to/problem`. – waltinator Aug 06 '21 at 21:35
  • I get this: `drwxr-xr-x 22 simon simon 4096 Aug 7 20:15 . /dev/nvme0n1p5 on / type ext4 (rw,relatime,errors=remount-ro)` How should I interpret that? – Teg Veece Aug 07 '21 at 10:16
  • Please [edit] your post to add new information, properly formatted. Information added via comments is hard for you to format, hard for us to read and ignored by future readers. Please click [edit] and add that vital information to your question so all the facts we need are in the question. Please don't use Add Comment, since that's our uplink to you. All facts about your system should go in the Question with [edit] – waltinator Aug 07 '21 at 13:02
  • Thanks. I've updated the original post. – Teg Veece Aug 07 '21 at 20:42
  • Since you're having a problem with `/home/simon/.vim/autoload`, not the current directory, you should `sudo code/pathlld.sh /home/simon/.vim/autoload` – waltinator Aug 08 '21 at 00:28
  • Thanks for your help so far. Two things: 1. That directory doesn't exist before I run the curl command (`curl` is supposed to create it). 2. The error happens even if I specifiy curl to make an output file in the home directory whose filename starts with a `.` (ie is hidden). It runs fine if the file name doesn't contain a hidden directory or filename. – Teg Veece Aug 08 '21 at 04:25

1 Answers1

11

Weirdly and coincidentally I had exactly the same problem as you. Not only with curl, but with Vim and Plug at the same time. Small world.

My guess to fix this was that it was a problem with the curl that I was using.

I had installed curl from the snap store:

sudo snap install curl

I then got the same error message as you:

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs     https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
Error creating directory /home/ian/.vim/autoload.
curl: (23) Failed writing received data to disk/application

My fix was to remove the snap curl and install the basic apt curl:

$ sudo snap remove curl
$ sudo apt install curl

and voila...

$ curl -fLo ~/.vim/autoload/plug.vim --create-dirs     https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 82784  100 82784    0     0   612k      0 --:--:-- --:--:-- --:--:--  612k
icc97
  • 645
  • 2
  • 8
  • 16
  • This worked for me too. Thanks! – lambda Nov 14 '21 at 16:59
  • 1
    For reference, this problem occurred with SDKMan as well and the reason is the same. Snap installation of curl removed and classic apt install solves the issue. – Sven Nov 30 '22 at 14:41