question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Go PATH not being passed to subprocesses (?)

See original GitHub issue

Kind of related to #107, but might be separate issue.

I have the following in my script:

    - name: Install Go
      uses: actions/setup-go@v3
      with:
        go-version: '>=1.18.0'
        check-latest: true

When I run this action:

    - run: |
        go version
        which go

it prints:

go version go1.18 linux/amd64
/opt/hostedtoolcache/go/1.18.0/x64/bin/go

I have a debuild script

    - run: |
        debuild -us -uc -ui

which has:

override_dh_auto_build:
	go version
	which go

which prints:

> go version
go version go1.15.15 linux/amd64
> which go
/usr/bin/go

I’m guessing 1.15.15 is preinstalled with the Ubuntu image, or something like that? I’m guessing this has to do with debuild (haven’t tested with other programs/scripts yet) not passing along PATH, but this stills seems like a catalyst for confusion (rather than getting go: command not found, all your builds are failing for no clear reason, or you’re compiling on an outdated version without knowing it).

I know that apt installs Go differently from the recommended way (I think it creates a symlink in /usr/bin), so I think that’s what the issue is. It’s the same thing as if you were to try running sudo go <something>, but export PATH=$PATH:/usr/local/go/bin was in your .bashrc, but not root’s; it would fallback onto the apt version (you can see in my example, I’m not running anything as root, but same result).

If that’s the case, it’s obviously not really a bug, but I think something could be done to prevent this from happening to people.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5

github_iconTop GitHub Comments

1reaction
Mexican-Mancommented, Apr 6, 2022

Thanks @vsafonkin! I tried a few different variants of that, but wasn’t able to get any of them to work. I was able to reassign the executable, but the go args did not carry over properly, and I ended up compiling 1.15 packages (all imported package errored with import cycle)

I was able to confirm that debuild does sanitize PATH (unless specified otherwise). It’s late now, so I’ll post back with more info later.

0reactions
Mexican-Mancommented, Apr 11, 2022

I did not work for me. I might have been doing something wrong though. Here’s what I did (from my commit):

+ sudo rm /usr/bin/go
+ sudo ln /usr/bin/go $(which go)

Looking back, I’m pretty sure root would expand $(which go), so I think I’m just an idiot. I’ll wait for #107 to resolve.

Read more comments on GitHub >

github_iconTop Results From Across the Web

python subprocess Popen environment PATH? - Stack Overflow
Popen acts relative to the current working directory, not the elements of the systems PATH.
Read more >
Can't pass Path like objects to subprocess api's on Windows.
Following code: ``` from pathlib import Path import os import subprocess dir_name = os.environ.get("WORKSPACE", None) or "." output_directory = ...
Read more >
os/exec - Go Packages
Package exec runs external commands. It wraps os.StartProcess to make it easier to remap stdin and stdout, connect I/O with pipes, and do...
Read more >
Tutorial - xonsh 0.13.4 documentation
While all Python code is also xonsh, not all Bash code can be used in xonsh. ... The only difference is that the...
Read more >
An Introduction to Subprocess in Python With Examples
The Python subprocess call() function returns the executed code of the program. If there is no program output, the function will return the ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found