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

don't default to binaries in the PATH #823

Merged
merged 5 commits into from
May 6, 2016
Merged

Conversation

luan
Copy link
Contributor

@luan luan commented Apr 27, 2016

I asked this on #188 but since that's a closed PR I feel like it's less likely to receive attention so I'm creating a new issue instead.

I have to start this with the question: is there any particular reason for append instead of prepend? This is causing issues if people have some other binary in their path with a colliding name, because appending makes our gobin the last lookup path rather than the first.

I'm getting several reports of people hitting this issue because they had tools compiled on 1.6 and were hanging out in their $GOPATH/bin and now that we're using g:go_bin_path that is not getting updated, short term fix for us is just removing those stale binaries but seems like a prepend to the $PATH would be appropriate.

I made this as a PR because this may be the right solution. I didn't think through all the edge cases here because I wanted to just get opinions on this first. It seems like surprising behavior to me that when I configure g:go_bin_path the $PATH still overrides it.

Thoughts?

if executable(binpath)
return binpath
endif

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason you removed this? This shouldn't be removed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, maybe this isn't the best way to do this, but, without that it always uses what's present in $PATH, regardless of the ordering changes. Maybe we should move the let $PATH line up above this block?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should use it from PATH. Can you please change it back? PATH is universal and it's ok to read it from there. It also makes the logic clear.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you see my updated changes?

@fatih
Copy link
Owner

fatih commented Apr 28, 2016

Hi @luan

The only reason is that PATH always comes first. Other than this there is no other significant reason. You have a valid concenr and I'm ok changing the order of the binary paths.

@luan
Copy link
Contributor Author

luan commented May 2, 2016

@fatih take a look at the updated changes, I added the temporary $PATH first and use exepath to resolve it.

" append our GOBIN and GOPATH paths and be sure they can be found there...
" let us search in our GOBIN and GOPATH paths
let old_path = $PATH
let $PATH = go_bin_path . go#util#PathListSep() . $PATH
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is wrong imho. This variable needs to be fetched first below. I think you need to revisit all the logic here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it is, sorry. I just realized I had my rtp set to something else when I was doing this. pushing a fish now.

@fatih
Copy link
Owner

fatih commented May 2, 2016

@luan Can you please check the logic. The variable go_bin_path needs to be first fetched. You need to change it as well.

@luan
Copy link
Contributor Author

luan commented May 3, 2016

@fatih yeah sorry. I moved those lines up. What do you mean I need to change it though?

@@ -139,26 +139,29 @@ function! go#path#CheckBinPath(binpath)
" remove whitespaces if user applied something like 'goimports '
let binpath = substitute(a:binpath, '^\s*\(.\{-}\)\s*$', '\1', '')

" check if we have an appropriate bin_path
let go_bin_path = go#path#BinPath()
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please handle the case when this is empty (it can be). You should handle it here, not below.

@luan
Copy link
Contributor Author

luan commented May 6, 2016

@fatih handled that case by not changing the PATH when go_bin_path isn't set, it no longer short circuits on that case and checks for executable(basename). There is a number of ways this could be done and this is the one that looked cleaner to me. Let me know what you think.

" append our GOBIN and GOPATH paths and be sure they can be found there...
" let us search in our GOBIN and GOPATH paths
let $PATH = go_bin_path . go#util#PathListSep() . $PATH
endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok I didn't quite get this. If go_bin_path is empty, this means we're going to prepend an empty string to PATH. Why do we prepend an empty string ? We shouldn't do that :)

@luan
Copy link
Contributor Author

luan commented May 6, 2016

@fatih yes... Fixed that.

@fatih fatih merged commit 62f8aa3 into fatih:master May 6, 2016
@fatih
Copy link
Owner

fatih commented May 6, 2016

Thanks @luan 👍

luan added a commit to luan/vim-go that referenced this pull request May 20, 2016
fatih#823 added this the wrong way, it was reverted back on 9f0cf00 but still not achieving the right functionality.
This uses it properly now, also adding it to how we lookup goimports for srcdir support.
luan added a commit to luan/vim-go that referenced this pull request May 20, 2016
 fatih#823 added this the wrong way, it was reverted back on 9f0cf00 but still not achieving the right functionality.
 This uses it properly now, also adding it to how we lookup goimports for srcdir support.
fatih pushed a commit that referenced this pull request Jun 1, 2016
* Properly use exepath for CheckBinPath

 #823 added this the wrong way, it was reverted back on 9f0cf00 but still not achieving the right functionality. This uses it properly now, also adding it to how we lookup goimports for srcdir support.
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

Successfully merging this pull request may close these issues.

2 participants