Skip to content

syntax checking fails (silently) when cargo is not in default path #126

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
conundrumer opened this issue Nov 26, 2016 · 15 comments
Closed

Comments

@conundrumer
Copy link

SyntaxCheckPlugin was not able to find cargo, but doesn't report not being able to find it, because the actual error message is /bin/sh: cargo: command not found, whereas the error checker looks for "error".

I installed Rust through rustup, so cargo is in $HOME/.cargo/bin. But the path of SyntaxCheckPlugin is the default: /usr/bin:/bin:/usr/sbin:/sbin. #92 did not address this plugin.

@jasonwilliams
Copy link
Member

@conundrumer interesting, we don't hardcode the path, so looks like the script isn't picking up the system path

@dten
Copy link

dten commented Nov 26, 2016

Seems we do set the path but only on OSX https://github.com/rust-lang/sublime-rust/blob/master/Cargo.sublime-build#L8
So I guess everyone on OSX build would work without changes but syntax check won't. Everybody else has to have cargo on the path beforehand.

@jasonwilliams
Copy link
Member

@conundrumer what OS are you running this on?

@conundrumer
Copy link
Author

@Jayflux this is on OSX. I will also note that the path to $HOME/.cargo/bin is set on my .bashrc. Also, the build commands work.

@jasonwilliams
Copy link
Member

I will run a couple of tests on my macbook and windows 10 later on, and see what the problem is.
Sounds like the script isn't seeing the outer path

@jcagpir
Copy link

jcagpir commented Nov 28, 2016

I have the same problem with Manjaro (ArchLinux based).
My shell path is : ".../usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/go/bin:/home/jcag/.cargo/bin"

"/home/jcag/.cargo/bin" is Cargo installation path, but when I try to build a rust file Sublime Text doesn't get the right value of the shell path and I get the message :
"[Errno 2] No such file or directory: 'cargo'"
...
"[path: /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/go/bin]"

@jasonwilliams
Copy link
Member

@wbond is it possible to get the user's env variables into the context of a sublime plugin?

@wbond
Copy link

wbond commented Nov 28, 2016

This only occurs on OS X because all applications are launched from the dock, which does not execute your shell, and thus does not have the same environment.

There is an enhancement that will be part of the next dev build that executes the user's default shell as a login shell and fetches their environment variables to get around this limitation of OS X.

@jcagpir
Copy link

jcagpir commented Nov 29, 2016

@wbond
It seems it occurs in Linux manjaro too. Here is the whole error message when I try to build "guessing_game" project:

"[Errno 2] No such file or directory: 'cargo'
[cmd: ['cargo', 'run'] // not "shell_cmd"
[dir: /home/jcag/Rust/Projects/guessing_game/src]
[path: /usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/go/bin]
[Finished]"

But my shell path is :

".../usr/local/sbin:/usr/local/bin:/usr/bin:/usr/lib/jvm/default/bin:/usr/lib32/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/usr/lib/go/bin:/home/jcag/.cargo/bin"

and "/home/jcag/.cargo/bin" is my Cargo installation path.
Sublime Text (Build 3126) is launched from the application menu and Rust Enhanced plugin was installed by Package Control.
What can I do ? Thanks in advance.

@wbond
Copy link

wbond commented Nov 29, 2016

@jcagpir That means that your env for your DE isn't set properly. It isn't really up to Sublime Text to manage that for you. In fact, it seems you've gotten your env set properly for Go, Java and Perl. You just need to configure Rust also.

We are adding the work-around for OS X since there isn't really a reasonable way to set the environment of the Dock process. There were some changes that worked on some versions of OS X, but it didn't work in many situations.

@jcagpir
Copy link

jcagpir commented Nov 29, 2016

@wbond Thanks for your answer.
Path env variable must be configured into "home/UserName/.bash_profile" file an not in "home/UserName/.bashrc". It consists in adding the line "export PATH=$PATH:/home/UserName/.cargo/bin"

@jasonwilliams
Copy link
Member

@conundrumer @jcagpir is this still a problem on the latest release?

@jasonwilliams
Copy link
Member

@conundrumer @jcagpir did the fix in #97 not address your issue?

@jasonwilliams
Copy link
Member

jasonwilliams commented Mar 15, 2017

ok looks like the issue is still there....
Im wondering if we can add ~/.cargo/bin to the path before we spawn the process?

I might give it a go as an experiment

http://stackoverflow.com/questions/2231227/python-subprocess-popen-with-a-modified-environment

jasonwilliams added a commit to jasonwilliams/rust-enhanced that referenced this issue Mar 15, 2017
@jasonwilliams
Copy link
Member

Provided a fix here: #166
Seems to work for me

jasonwilliams pushed a commit to jasonwilliams/rust-enhanced that referenced this issue Mar 15, 2017
jasonwilliams pushed a commit to jasonwilliams/rust-enhanced that referenced this issue Mar 15, 2017
jasonwilliams added a commit to jasonwilliams/rust-enhanced that referenced this issue Mar 15, 2017
urschrei pushed a commit to urschrei/sublime-rust that referenced this issue Jan 30, 2018
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