Score:4

Can't write to a hidden path using Curl

ru flag

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?

waltinator avatar
it flag
Explore your permission/ownership problems with `https://github.com/waltinator/pathlld`. A `bash` script to answer "Why can't I Read/Write that file?".
Teg Veece avatar
ru flag
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
waltinator avatar
it flag
Type `sudo /path/to/pathlld.sh /path/to/problem`.
Teg Veece avatar
ru flag
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?
waltinator avatar
it flag
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]
Teg Veece avatar
ru flag
Thanks. I've updated the original post.
waltinator avatar
it flag
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`
Teg Veece avatar
ru flag
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.
Score:4
cn flag

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
gan avatar
it flag
gan
This worked for me too. Thanks!
is flag
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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.