-
Notifications
You must be signed in to change notification settings - Fork 38
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
Fixing 'nim' binary could not be found in PATH on OS X #52
Conversation
src/nimUtils.ts
Outdated
if (process.platform === 'darwin') { | ||
// dirty hack because the version of readlink that ships with osx doesn't support the -f flag | ||
// from https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac#4031502 | ||
buff = cp.execFileSync('python', ['-c', 'import os,sys;print(os.path.realpath(sys.argv[1]))', _pathesCache[tool]]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont think that use python here is a good idea may be it will enough construct full path from _pathesCache[tool] + cp.execFileSync('readlink', [_pathesCache[tool]])
in case of relative symlink
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are totally right, depending on python is not a good idea.
I fixed it as you suggested, by appending the relative path to the symlink path in 1d328ad.
src/nimUtils.ts
Outdated
// dirty hack because the version of readlink that ships with osx doesn't support the -f flag | ||
// from https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac#4031502 | ||
buff = cp.execFileSync('python', ['-c', 'import os,sys;print(os.path.realpath(sys.argv[1]))', _pathesCache[tool]]); | ||
nimPath = _pathesCache[tool].slice(0, _pathesCache[tool].length - 3) + cp.execFileSync('readlink', [_pathesCache[tool]]).toString().trim(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess it will not work for all cases becasue link can be relative or absolute and you need prepend _pathesCache[tool].slice(0, _pathesCache[tool].length - 3)
only in case of relative path (not start with /
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I can tell, readlink
always returns a path relative to the parent of the symlink and thus will never have a /
in front.
But as a general question, why do you need to resolve the symlink for nim
anyway? It works totally fine for me if I use the path to nim thats in my PATH
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It need locate nimsuggest executable that are placed together with nim executable
I'm sorry, but when will this feature be released? |
Sorry for delay, it was released recently in 0.5.24 version |
Thank you very much! |
The output of
readlink
without the -f flag is a non absolute path. As a result, if you used brew to install nim, the correct binary can't be detected and the error message is shown.See https://stackoverflow.com/questions/1055671/how-can-i-get-the-behavior-of-gnus-readlink-f-on-a-mac#4031502 on the readlink problem and a solution.
My solution is a bit hacky but should work on all OS X versions.