cli icon indicating copy to clipboard operation
cli copied to clipboard

--config flag doesn't handle ~ for home dir

Open kytrinyx opened this issue 11 years ago • 13 comments

$ exercism --config=~/hello.json configure --key=abc123
2015/01/11 19:49:00 open ~/hello.json: no such file or directory

vs

$ exercism --config=/tmp/hello.json configure --key=abc123
The configuration has been written to /tmp/hello.json
Your exercism directory can be found at /Users/kytrinyx/exercism

kytrinyx avatar Jan 12 '15 03:01 kytrinyx

The command works if you omit the = for config; which allows the shell to expand the path.

$ exercism --config ~/hello.json configure --key=abc123
The configuration has been written to /Users/cdambrosio/hello.json
Your exercism directory can be found at /Users/cdambrosio/exercism

chrisdambrosio avatar Jan 12 '15 21:01 chrisdambrosio

@chrisdambrosio that seems like a good workaround. We should still have the CLI expand the path though.

Tonkpils avatar Jan 12 '15 21:01 Tonkpils

How could one set the folder of the configuration file in the current release (v3.0.11)?

I would like to set the configuration folder to be the folder the file exercism.exe is in.

RoyiAvital avatar Feb 27 '19 19:02 RoyiAvital

For windows you have chance, other than changing APPDATA, which I wouldn't advice to do. In general, saving the configuration or other user generated data in the installation folder is actively discouraged by Microsoft since the release of windows XP.

NobbZ avatar Feb 27 '19 20:02 NobbZ

You can also set EXERCISM_CONFIG_HOME

kytrinyx avatar Feb 28 '19 00:02 kytrinyx

Which is not respected when runtime.GOOS is "windows":

https://github.com/exercism/cli/blob/master/config/config.go#L56-L73

NobbZ avatar Feb 28 '19 09:02 NobbZ

For windows you have chance, other than changing APPDATA, which I wouldn't advice to do. In general, saving the configuration or other user generated data in the installation folder is actively discouraged by Microsoft since the release of windows XP.

This idea is perfect for a computer with multiple users. I'm the sole user on my computer and I prefer each program to be portable. I hate when I format the computer to see programs must be installed and configured again.

RoyiAvital avatar Feb 28 '19 14:02 RoyiAvital

@NobbZ Good point.

@RoyiAvital Would it help if we respected the EXERCISM_CONFIG_HOME env var for Windows too? (If so, let's open a new issue that specifies that change).

kytrinyx avatar Feb 28 '19 15:02 kytrinyx

@kytrinyx , I don't think so. As if I need to set system Variable I can set %APPDATA. I thought about an elegant (In my opinion) solution like if the EXE sees a .portable file in the folder it will use the working folder for the configuration file. This will also mean that every time it has to read the configuration file it will see the file and will understand where to look for the file.

RoyiAvital avatar Feb 28 '19 15:02 RoyiAvital

@RoyiAvital I'm not opposed to that solution. Would you open an issue to discuss it?

kytrinyx avatar Feb 28 '19 15:02 kytrinyx

@kytrinyx @RoyiAvital Would it be necessary to add the .portable file to the folder? Would it not work just as well to have exercism.exe initially look inside the same folder for the user.json file and read the contents from there if the file is found, falling back to reading from %APPDATA if the file can't be found? This would make the solution just as portable and not require an additional file.

craigtp avatar Nov 04 '19 10:11 craigtp

@craigtp , Yes, it will work. When I wrote my example it was the concept looking in the working folder before going out. What to look should be engineering decision.

RoyiAvital avatar Nov 04 '19 10:11 RoyiAvital

@RoyiAvital Personally, I'd be happy with either approach, as I too would like a completely portable folder for Exercism. I have the exercism.exe file (and required dependencies) and all my source code and a git repo in a single folder. Would be great to be able to simply copy that folder to another PC and have everything "just work". Only thing stopped that currently is the requirement on the user.json file being located in %APPDATA.

craigtp avatar Nov 04 '19 10:11 craigtp