Open DmitryPogrebnoy opened 9 months ago
I spent some time and found a workaround for that. So you need to refresh bash in order to apply .bashrc and activate mise: SHELL ["/bin/bash", "--login" ,"-c"]
@jdx This issue also reproduces when mise is not activated and you try to install/uninstall some gems using ~/.local/bin/mise exec --quiet ruby@3.3.0 -- gem uninstall <gem_name>
. Is there any way to fix this?
Here is full stacktrace of the error:
11:53:27,522 FINE plugins.ruby.gem.gem.GemRunner - stderr: ERROR: While executing gem ... (Errno::ENOENT)
11:53:27,522 FINE plugins.ruby.gem.gem.GemRunner - stderr: No such file or directory - mise
11:53:27,522 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/rubygems_plugin/rubygems_plugin.rb:14:in ``'
11:53:27,522 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/rubygems_plugin/rubygems_plugin.rb:14:in `reshim'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/rubygems_plugin/rubygems_plugin.rb:38:in `block in <top (required)>'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:170:in `block in uninstall_gem'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:169:in `each'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:169:in `uninstall_gem'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:234:in `block in remove_all'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:234:in `each'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:234:in `remove_all'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/uninstaller.rb:125:in `uninstall'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:197:in `uninstall'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:183:in `uninstall_gem'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:178:in `block in uninstall_specific'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:170:in `each'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:170:in `uninstall_specific'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/commands/uninstall_command.rb:132:in `execute'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/command.rb:326:in `invoke_with_build_args'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/command_manager.rb:254:in `invoke_command'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/command_manager.rb:193:in `process_args'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/command_manager.rb:151:in `run'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/lib/ruby/site_ruby/3.3.0/rubygems/gem_runner.rb:56:in `run'
11:53:27,523 FINE plugins.ruby.gem.gem.GemRunner - stderr: /home/user/.local/share/mise/installs/ruby/3.3.0/bin/gem:12:in `<main>'
you need to add it to PATH. Also, activation is only for interactive sessions.
@jdx Well, a command ENV PATH="~/.local/bin/mise:${PATH}"
after mise installation and before any other mise commands doesn't do the trick. But ENV PATH="~/.local/bin:${PATH}"
does. Thank you! It would be nice if you add a notion about adding mise to PATH in that section - https://mise.jdx.dev/dev-tools/shims.html#neither-shims-nor-path.
@jdx Nevertheless, adding mise to PATH doesn't help for jruby-9.4.5.0. Stacktrace more or less the same:
ERROR: While executing gem ... (Errno::ENOENT)
21:48:41 No such file or directory - mise
21:48:41 org/jruby/RubyKernel.java:1745:in ``'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/rubygems_plugin/rubygems_plugin.rb:1:in `reshim'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/rubygems_plugin/rubygems_plugin.rb:38:in `block in <main>'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/uninstaller.rb:170:in `block in uninstall_gem'
21:48:41 org/jruby/RubyArray.java:1989:in `each'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/uninstaller.rb:169:in `uninstall_gem'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/uninstaller.rb:234:in `block in remove_all'
21:48:41 org/jruby/RubyArray.java:1989:in `each'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/uninstaller.rb:234:in `remove_all'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/uninstaller.rb:125:in `uninstall'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/commands/uninstall_command.rb:197:in `uninstall'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/commands/uninstall_command.rb:183:in `uninstall_gem'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/commands/uninstall_command.rb:178:in `block in uninstall_specific'
21:48:41 org/jruby/RubyArray.java:1989:in `each'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/commands/uninstall_command.rb:170:in `uninstall_specific'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/commands/uninstall_command.rb:132:in `execute'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/command.rb:326:in `invoke_with_build_args'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/command_manager.rb:254:in `invoke_command'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/command_manager.rb:193:in `process_args'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/command_manager.rb:151:in `run'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/lib/ruby/stdlib/rubygems/gem_runner.rb:56:in `run'
21:48:41 /home/user/.local/share/mise/installs/ruby/jruby-9.4.5.0/bin/jgem:21:in `<main>'
Any ways to fix this?
looks like it still isn't on PATH
Well, for some reason, ENV PATH="~/.local/bin:${PATH}"
doesn't work for jruby, but full path ENV PATH="home/user/.local/bin:${PATH}"
works. Probably it would also be good to mention it in documentation.
I don't think ~
has any guarantees to work or expand consistently in usage. If I recall correctly it doesn't work in alpine linux for example. In most scenarios, bash, etc is doing the expansion first (via an os call) before being passed to a binary.
I suspect your use case it's passed through to jruby
directly and it does not expand for you. For that matter I'd be curious if cruby
behaves differently.
You are using single quotes which do not expand variables. Try double quoting. For good measure you could also use $HOME
as well.
@jdx Another case when I get an error with unresolved mise
command. I use noninteractive shell without login, so <path to mise>/mise activate
is not invoked. And I use command like bash -c '<path to mise>/mise exec ruby@3.3.0 -- <path to ruby>/ruby <path to bundle>/bundle install'
. And I get an error like above:
ERROR: While executing gem ... (Errno::ENOENT)
No such file or directory - mise
Adding mise path to PATH in bashrc
file or any other shell configuration file doesn't help in the case of noninteractive shell without login.
So if you use non-absolute paths in scripts, please add path to mise inside exec command. For now I have to use a workaround like this every time when I need to exec something:
bash -c 'export PATH=$PATH:<path to mise> && <path to mise>/mise exec ruby@3.3.0 -- <path to ruby>/ruby <path to bundle>/bundle install'
.
Describe the bug The problem is with mise and rubygems update when building Docker image.
To Reproduce Steps to reproduce the behavior. 1) Create Dockerfile like this:
The first part of the Dockerfile - after
## basic image configuration for ruby
comment. It is just a template without something specific for that issue.The second part -- after
## mise configuration
comment. It is relevant stuff for this issue. There we install mise, then we try to install ruby@2.6.10 and update rubygems to the latest compatible version.2) Try to build docker image from that Dockerfile. 3) Build process will fail with an error message like this:
The problem appears with the command
~/.local/bin/mise exec ruby@$_RUBY_VERSION -- gem update --no-document --system 3.4.22
. Basically it can't resolve mise somewhere in scripts. I debugged and found that the problem is insrc/plugins/core/assets/rubygems_plugin.rb
script at the line 14 -mise reshim
. https://github.com/jdx/mise/blob/c6d4a4a7541cb6d226ebfad6f7eb6b377c64519d/src/plugins/core/assets/rubygems_plugin.rb#L14C1-L14C18 So I guess that there it assumes that mise can be resolved, but it doesn't. It is because mise is not activated because we are in non-interactive mode in Dockerfile. So the possible fix is to use full path to mise.If I misunderstood something please let me know and explain the right way.
Expected behavior A clear and concise description of what you expected to happen.
Command
~/.local/bin/mise exec ruby@$_RUBY_VERSION -- gem update --no-document --system 3.4.22
should work fine. Dockerfile should be built without any errors from mise.mise doctor
outputOutput of
mise doctor
after installing mise in DockerfileAdditional context Add any other context about the problem here.