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

Unknown command when running Homebrew test #794

Closed
dnicolson opened this issue Sep 2, 2020 · 13 comments
Closed

Unknown command when running Homebrew test #794

dnicolson opened this issue Sep 2, 2020 · 13 comments

Comments

@dnicolson
Copy link
Contributor

Describe the bug

Running Homebrew tests that require binaries managed by asdf can fail, in this instance with this message:
unknown command: node. Perhaps you have to reshim?

This appears to be because in the test environment the HOME environment variable is changed by Homebrew. It appears as though asdf depends on this.

Homebrew Node.js installations and nvm do not have this problem, but as mentioned in #785 maybe this is unavoidable and should just be added to the Common Homebrew Issues section?

To Reproduce

  1. brew update
  2. brew install emscripten
  3. brew test emscripten

Expected behavior

The test to run.

Actual behavior

The node command was not found.

@jthegedus
Copy link
Contributor

jthegedus commented Sep 2, 2020

Thanks for reporting @dnicolson

If the ASDF_DATA_DIR env var was used would this issue be resolved? Perhaps we should recommend as much to Homebrew users if this is the case? 🤔

Can you perform a test of this?

We should also have a test case for this since we have many Homebrew users.

@dnicolson
Copy link
Contributor Author

Setting the ASDF_DATA_DIR environment variable doesn't seem to have any effect.

There is a predefined list (Java, Go, Rust, CURL) of environment variables that are included in the Homebrew test environment.

Adding ASDF_DATA_DIR to that list resolves the issue, but then there is the familiar warning:
asdf: No version set for command node

This is only an issue with locally developing Homebrew test methods though (CI works fine), so maybe it should just be documented as a caveat.

@jthegedus
Copy link
Contributor

This is only an issue with locally developing Homebrew test methods
This seems very odd.

asdf only relies upon $HOME/.asdf as the default location to lookup shims/plugins etc, so if ASDF_DATA_DIR is set outside of $HOME then Homebrew shouldn't be able to affect this and the lookup of the tool should work.

Can you ensure your test is with ASDF_DATA_DIR outside of $HOME?

maybe it should just be documented as a caveat

We should document this, yes, but I would like to investigate and understand the root cause completely

@dnicolson
Copy link
Contributor Author

Can you ensure your test is with ASDF_DATA_DIR outside of $HOME?

I tried setting ASDF_DATA_DIR to /tmp but it made no difference.

The environment variables seem to be ignored in the test sandbox. Only by manually adding ASDF_DATA_DIR to the Homebrew formula.rb file was I able to see any results.

@jthegedus
Copy link
Contributor

was I able to see any results.

But those results were the asdf: No version set for command node error you mentioned above? Is this completely resolved if you were to set a local node version in the test environment also?

@dnicolson
Copy link
Contributor Author

Running asdf local nodejs 12.16.1 didn't change anything.

@jthegedus
Copy link
Contributor

Sorry, I wasn't very clear. In the Homebrew test environment, where you added asdf_data_dir, can you also have it set the node version there?

@dnicolson
Copy link
Contributor Author

Running system("asdf local nodejs 12.16.1") in formula.rb results in the following output:

asdf local nodejs 12.16.1

sed: /Users/dave/Dropbox/Mackup/.tool-versions: Operation not permitted
rm: /Users/dave/Dropbox/Mackup/.tool-versions.bak: No such file or directory

@jthegedus
Copy link
Contributor

Okay then, seems like this is going to be an annoying issue to document. So what workarounds should we document that will allow users to get brew test <xyz> to work?

@dnicolson
Copy link
Contributor Author

More investigation would be needed on how the Homebrew test environment works. I simply uninstalled asdf to get the tests to work.

@jthegedus
Copy link
Contributor

jthegedus commented Sep 4, 2020

I simply uninstalled asdf

Hardly an ideal solution.

Interesting that sed was not permitted. For documentation purposes, that sed call occurs in https://github.com/asdf-vm/asdf/blob/master/lib/commands/version_commands.bash#L44 as a downstream call from https://github.com/asdf-vm/asdf/blob/master/lib/commands/command-local.bash

Would you consider me adding this to the Homebrew caveats Issue a resolution for this Issue and thus able to be closed?

[Edit]: added to #785 (Common Homebrew Issues)

@dnicolson
Copy link
Contributor Author

Sure, I think that's the best outcome for now.

@happyfloat
Copy link

happyfloat commented Apr 11, 2024

Is there any solution to this? I also run into the same issue if I want to run my cloud functions locally:
https://ion.sst.dev/docs/live/
I'm using the git version instead of homebrew for asdf.

Edit rm -rf ~/.asdf/shims; asdf reshim fixed it!

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

3 participants