Skip to content

arduino-cli uses wrong home directory on MacOS after new install/migration from a time machine backup with home directory name change #1114

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
plocher opened this issue Dec 26, 2020 · 9 comments

Comments

@plocher
Copy link

plocher commented Dec 26, 2020

The directory search order for the config file is supposed to use $HOME...

jplocher@iMac-Pro ~ % echo $HOME
/Users/jplocher

note the "jplocher"...

Running the command from /Users/jplocher/:

jplocher@iMac-Pro ~ % arduino-cli --verbose config init
Error creating inventory dir: mkdir /Users/plocher: permission denied
ERRO[0000] Error creating inventory dir: mkdir /Users/plocher: permission denied 
Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory
ERRO[0000] Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory 
INFO[0000] Using config file: /Users/jplocher/Library/Arduino15/arduino-cli.yaml 
INFO[0000] arduino-cli version 0.14.0                   
INFO[0000] Writing config file to: /Users/plocher/Library/Arduino15 
Cannot create config file directory: mkdir /Users/plocher: permission denied
ERRO[0000] Cannot create config file directory: mkdir /Users/plocher: permission denied 

Where is the "/Users/plocher" (without the 'j') coming from?

the "plocher" directory name is not in Apple Preferences/Users, not in /etc/passwd, not in $ENV...
Could it be stored somewhere else that came from a different / previous installation elsewhere where that
home directory name had been used?

jplocher@iMac-Pro ~ % arduino-cli --verbose version
Error creating inventory dir: mkdir /Users/plocher: permission denied
ERRO[0000] Error creating inventory dir: mkdir /Users/plocher: permission denied 
Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory
ERRO[0000] Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory 
INFO[0000] Using config file: /Users/jplocher/Library/Arduino15/arduino-cli.yaml 
INFO[0000] arduino-cli version 0.14.0                   
arduino-cli alpha Version: 0.14.0 Commit: a86b21d99e2af9e0857da0ce4ab80baf1d3afb55 Date: 
@plocher
Copy link
Author

plocher commented Dec 26, 2020

The startup code path in arduino-cli reads in ~/Library/Arduino15/arduino-cli.yaml

Root cause: This file is copied over by Apple's computer install/migration update process from a backup - even when the home directory names on the two computers are different.

Bug: if the contents of this file are wrong, there is no indication in the error messages of what went wrong or how to find, assess and fix it...

Suggested fix:
If the directories found in this file are invalid, catch the error and do something constructive about it.

Possibilities:

  • if the command is config init, ignore the info in this file and overwrite it with valid directory names.
  • tell the user the name of this file (~/Library/Arduino15/arduino-cli.yaml) and highlight the incorrect directories found in it.
  • ignore this file and write a new arduino-cli.yaml file in the current directory.
  • ...etc...

@plocher
Copy link
Author

plocher commented Dec 26, 2020

Work Around:

  • Edit (or simply remove) the file ~/Library/Arduino15/arduino-cli.yaml

@plocher plocher changed the title arduino-cli uses wrong home directory on MacOS arduino-cli uses wrong home directory on MacOS after new install/migration from a time machine backup with home directory name change Dec 26, 2020
@ubidefeo
Copy link

hi @plocher

Bug: if the contents of this file are wrong, there is no indication in the error messages of what went wrong or how to find, assess and fix it...

Suggested fix:
If the directories found in this file are invalid, catch the error and do something constructive about it.

extremely good catch!
thank you for reporting it, we'll look into it :)

@silvanocerza
Copy link
Contributor

I've investigated a bit and we can't solve this because there's nothing to solve really.

The CLI is correctly failing in this case, if the paths are not valid is the user's responsability to update them to valid ones.
If those paths don't exist the next time the CLI is run it tries to create them, this is done to gracefully handle first runs and whenever those paths are changed by the user.

The CLI can't know wether there is a typo in the path or it's malformed in some other way so it just goes along with it and returns an error as soon as it happens.

@ubidefeo
Copy link

@silvanocerza agreed

@plocher I hope you'll agree with this

@plocher
Copy link
Author

plocher commented Jan 11, 2021 via email

@per1234
Copy link
Contributor

per1234 commented Jan 11, 2021

The info on the web about arduino-cli is not at all clear on these files
names or exact locations.

@plocher did you see this section of the Arduino CLI configuration documentation page?:
https://arduino.github.io/arduino-cli/dev/configuration/#configuration-file
To me, it seems clear about the filenames and locations, but I'm already so familiar with this subject matter that it's easy for me to miss deficiencies in the documentation. If you have any suggestions for improvement to that documentation it would be welcome.

@plocher
Copy link
Author

plocher commented Jan 11, 2021

The "fix" I'm asking for is simply to add context to the initial error message output, which devotes 7 lines to the WRONG pathname and only one to the place to fix it :-)

jplocher@iMac-Pro ~ % arduino-cli --verbose config init
Error creating inventory dir: mkdir /Users/plocher: permission denied
ERRO[0000] Error creating inventory dir: mkdir /Users/plocher: permission denied 
Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory
ERRO[0000] Error writing inventory file: open /Users/plocher/Library/Arduino15/inventory.yaml: no such file or directory 

INFO[0000] invalid directory path specified in directories.data: /Users/plocher/Library/Arduino15
INFO[0000] Found in config file: /Users/jplocher/Library/Arduino15/arduino-cli.yaml

INFO[0000] arduino-cli version 0.14.0                   
INFO[0000] Writing config file to: /Users/plocher/Library/Arduino15 
Cannot create config file directory: mkdir /Users/plocher: permission denied
ERRO[0000] Cannot create config file directory: mkdir /Users/plocher: permission denied 

As an aside, one COULD make the call that arduino-cli config init SHOULD overwrite the existing arduino-cli.yaml file in the user's Arduino15 system library directory WITHOUT first reading it, in which case the user would be able to fix this problem without having to invoke an editor ...

@silvanocerza
Copy link
Contributor

The "fix" I'm asking for is simply to add context to the initial error message output, which devotes 7 lines to the WRONG pathname and only one to the place to fix it :-)

This makes sense. I can do something like this but I can't point where the path is read from without refactoring a big chunk of code.

Error: invalid path creating config dir: /home/<username>/.arduino15 error: mkdir /home/<username>: permission denied

As an aside, one COULD make the call that arduino-cli config init SHOULD overwrite the existing arduino-cli.yaml file in the user's Arduino15 system library directory WITHOUT first reading it, in which case the user would be able to fix this problem without having to invoke an editor ...

Yeah, I wish for that too. The config file handling needs a big refactoring, that takes time to plan and execute it without breaking anything. It's not something that we can work on right now sadly.

By the way remember that you must use the --overwrite flag when calling config init if there's an already existing config file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants