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

asdf in background #393

Closed
nikhilbhatt opened this issue Apr 17, 2024 · 4 comments
Closed

asdf in background #393

nikhilbhatt opened this issue Apr 17, 2024 · 4 comments

Comments

@nikhilbhatt
Copy link

When running gem install rake from terminal, zshrc gets loaded and gem install rake command runs successfully.

Now when I am trying to run it as background process gem intall rake it will not work. workaround for this will be to use full path.

$HOME/.asdf/shims/gem install rake By running this it introduces new error. here in below line we are using asdf directly. because in background we can not use asdf directly.

`asdf reshim ruby #{RUBY_VERSION} bin/#{executable}`

Please let me know If I am missing something here. or is there any other way to handle this?

@Stratus3D
Copy link
Member

Now when I am trying to run it as background process gem intall rake it will not work.

Can you provide details on this? How did it not work? Did it print an error?

Also, how did you run it as a background process?

@nikhilbhatt
Copy link
Author

nikhilbhatt commented Apr 30, 2024

Error log for the bundle install
I just updated actual path with $HOME in logs.

Errno::ENOENT: No such file or directory - asdf
  $HOME/.asdf/plugins/ruby/rubygems-plugin/rubygems_plugin.rb:5:in ``'
  $HOME/.asdf/plugins/ruby/rubygems-plugin/rubygems_plugin.rb:5:in `install'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/installer.rb:89:in `block in run'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/process_lock.rb:12:in `block in lock'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/process_lock.rb:9:in `open'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/process_lock.rb:9:in `lock'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/installer.rb:71:in `run'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/installer.rb:23:in `install'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/cli/install.rb:62:in `run'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/cli.rb:261:in `block in install'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/settings.rb:130:in `temporary'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/cli.rb:260:in `install'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/cli.rb:34:in `dispatch'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/cli.rb:28:in `start'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/exe/bundle:37:in `block in <top (required)>'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/lib/bundler/friendly_errors.rb:117:in `with_friendly_errors'
  $HOME/.asdf/installs/ruby/3.1.2/lib/ruby/gems/3.1.0/gems/bundler-2.4.19/exe/bundle:29:in `<top (required)>'
  $HOME/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `load'
  $HOME/.asdf/installs/ruby/3.1.2/bin/bundle:25:in `<main>'

Also, how did you run it as a background process?

I am using chef to run bundle install.
command ran -> $HOME/.asdf/shims/bundle install

@Stratus3D
Copy link
Member

You should never invoke shims directly. Instead of $HOME/.asdf/shims/bundle install you should run bundle install or asdf exec bundle install. Regardless, the asdf code will determine the version by looking at the directory the command was invoked in.

I don't know where Chef is invoking your bundle install command, but if you don't have a Ruby version set for that directory in asdf it won't work and would typically print a message like this:

unknown command: shellcheck. Perhaps you have to reshim?

It's not clear to me what the stacktrace above means, as that's not from asdf, but I'd double check that you've followed all the steps in the asdf installation instructions.

@nikhilbhatt
Copy link
Author

It's different error, Actually I got this working after loading up the environment variables when running the command,

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

2 participants