Skip to content
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

Using alt def with relative paths results in crash when running binary from different directory #274

Closed
dotboris opened this issue Dec 30, 2022 · 0 comments · Fixed by #280
Assignees
Labels
bug Something isn't working

Comments

@dotboris
Copy link
Owner

Here's a simple example:

$ alt def node 18 ./opt/node-18.12.1/bin/node
$ alt use node 18
Will now use node 18 (./opt/node-18.12.1/bin/node) when in /home/dotboris
$ node --version
v18.12.1
$ cd code/dotboris-io
$ alt show
Versions from: /home/dotboris/code/dotboris-io/.alt.toml
node
 * 18 (./opt/node-18.12.1/bin/node)
python (using system)
   3 (/usr/bin/python3)
$ node --version
🔥 alt failed to run node version 18!
error: Os { code: 2, kind: NotFound, message: "No such file or directory" }
command: node
command version: 18
args: ["--version"]
bin: ./opt/node-18.12.1/bin/node
current dir: Ok("/home/dotboris/code/dotboris-io")
thread 'main' panicked at 'explicit panic', src/exec_cmd.rs:47:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

The core of the issue is that alt def takes the path its given as is and stores it. When this path is relative, it's sensitive to the current directory which doesn't work in most cases.

The simple solution here is to make the path absolute before storing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant