Overview
I am developing using RubyMine.
I wanted to use RubyMine's debugging function as excellent, I got an error.
Detail
Add a break point
↓
Debug button pressed
↓
console
/bin/zsh -c "bash -c 'env RBENV_VERSION=2.7.1 /Users/katahira/.rbenv/libexec/rbenv exec ruby /Users/katahira/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/ruby-debug-ide-2.3.0/bin/rdebug-ide --key-value --step-over-in-blocks --disable-int-handler --evaluation-timeout 10 --evaluation-control --time-limit 100 --memory-limit 0 --rubymine-protocol-extensions --port 53995 --host 0.0.0.0 --dispatcher-port 53996 -- /Users/katahira/dev/work/〇〇.rb'"
Fast Debugger (ruby-debug-ide 2.3.0, debase 2.3.0, file filtering is supported, block breakpoints supported, smart steps supported, obtaining return values supported, partial obtaining of instance variables supported) listens on 0.0.0.0:53995
Uncaught exception: uninitialized constant Api
/Users/katahira/dev/work/〇〇.rb:1:in `<top (required)>'
Process finished with exit code 1
Tried
Check version
katahira#MBP 〇〇 % rbenv versions
system
2.4.1
2.5.8
2.6.3
2.6.5
2.7.0
* 2.7.1 (set by /Users/katahira/dev/work/〇〇/.ruby-version)←current directory
2.7.2
3.0.0
RubyMine → preferences → Ruby SDK Gem
rbenv: 2.7.1
Check gem
RubyMine → Preferences → Ruby SDK Gem → rbenv:2.7.1
ruby-debug-ide 2.3.0
・
・
・
debase
debase 2.3.0
debase
Environment
OS macOS BigSur
ruby 2.7.1 (2.6.5 is described in the gemfile)
rails 6.0.4('~> 6.0.3', '>= 6.0.3.7' is described in the gemfile)
docker Baseimage FROM ruby:2.6.5-alpine
Related
I'm trying to debug a Rails project within RubyMine v2018.2 (2018.2.1, 2018.2.4). When I start the editor I get a warning:
RubyMine Gem Manager: RubyMine has detected that some of the gems required for 'project' are not installed.
When I try to run RubyMine's Bundler install command I'm told
bash -c "RBENV_VERSION=2.5.0 /usr/bin/rbenv exec bundle install -V"
Activating bundler (< 2) failed:
Could not find 'bundler' (< 2) among 28 total gem(s)
Checked in 'GEM_PATH=/home/brad/.gem/ruby/2.5.0:/var/lib/gems/2.5.0:/usr/lib/x86_64-linux-gnu/rubygems-integration/2.5.0:/usr/share/rubygems-integration/2.5.0:/usr/share/rubygems-integration/all', execute `gem env` for more information
To install the version of bundler this project requires, run `gem install bundler -v '< 2'`
...and when I try to run or debug my application from the IDE I'm told "Could not find bundler (version) required by your project-path/Gemfile.lock."
Why doesn't RubyMine detect my installed Gems?
My environment
Ubuntu 18.04.01
zsh 5.4.2
rbenv 1.0.0
rbenv-binstubs # 8ecb7ca8
Rubymine 2018.2.4
I'm using rbenv to manage my Ruby versions. The system has Ruby 2.5.1 installed, but my project depends on 2.5.0. I've set 2.5.0 as the rbenv global version. Configuration for how rbenv chooses a Ruby version seems okay; I get the following results from the noninteractive commands:
> echo $RBENV_VERSION
(no response)
> cat ~/.rbenv/version
2.5.0
> rbenv global
2.5.0
After noticing rbenv wasn't working properly in some RubyMine commands I moved the eval "$(rbenv init -)" setup step from by ~/.zshrc up to ~/.zshenv and ~/.profile so it will also apply to bash and zsh login shells (per guidance here). I'm now getting matching results for interactive and login shells, but still getting unexpected behavior from the Bundle install command within RubyMine.
What is working
My application installs, builds and runs just fine from an interactive shell.
RubyMine's Ruby SDK settings correctly detect rvm and its installed versions, and all of the installed gems for that version.
What I've tried
The output from the bundle install command claims it's running
bash -c "RBENV_VERSION=2.5.0 /usr/bin/rbenv exec bundle install"
When I run this from my interactive shell or with RubyMine's "Run anything" feature (login shell) this command works fine - as does any of the following:
RBENV_VERSION=2.5.0 /usr/bin/rbenv exec bundle install
/usr/bin/rbenv exec bundle install
rbenv exec bundle install
bundle install
So I can't figure out what context RubyMine is using to run this command. It's clear from the error message that the GEM_PATH is incorrect, causing RubyMine to look in the wrong place for bundler, but I don't know where it's getting this configuration. If I bring up the "RubyGems Environment" view in RubyMine I get:
RUBYGEMS VERSION: 2.7.3
RUBY VERSION: 2.5.0 (2017-12-25 patchlevel 0) [x86_64-linux]
INSTALLATION DIRECTORY: /home/brad/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
USER INSTALLATION DIRECTORY: /home/brad/.gem/ruby/2.5.0
RUBY EXECUTABLE: /home/brad/.rbenv/versions/2.5.0/bin/ruby
EXECUTABLE DIRECTORY: /home/brad/.rbenv/versions/2.5.0/bin
SPEC CACHE DIRECTORY: /home/brad/.gem/specs
SYSTEM CONFIGURATION DIRECTORY: /home/brad/.rbenv/versions/2.5.0/etc
RUBYGEMS PLATFORMS:
ruby
x86_64-linux
GEM PATHS:
/home/brad/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0
/home/brad/.gem/ruby/2.5.0
(...)
SHELL PATH:
/home/brad/.rbenv/versions/2.5.0/bin
/usr/lib/rbenv/libexec
/home/brad/.rbenv/plugins/ruby-build/bin
/home/brad/.rbenv/plugins/rbenv-gemset/bin
/home/brad/.rbenv/plugins/rbenv-binstubs/bin
(...rest of PATH...)
----------------------
IDE: RubyMine 2018.2.4, build #RM-182.4505.55
OS: Linux 4.15.0-38-generic[amd64]
Java: 1.8.0_152-release-1248-b8
RubyMine SDK Environment:
Sdk: rbenv: 2.5.0
Sdk Version: ver.2.5.0p0 ( revision 61468) p0
Ruby Interpreter: /home/brad/.rbenv/versions/2.5.0/bin/ruby
RVM Sdk: Rbenv sdk, gemset nullSdk Language Level: 2.5
Sdk Load Path:
~/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/did_you_mean-1.2.0/lib
~/.rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0
~/.rbenv/versions/2.5.0/lib/ruby/site_ruby/2.5.0/x86_64-linux
~/.rbenv/versions/2.5.0/lib/ruby/site_ruby
~/.rbenv/versions/2.5.0/lib/ruby/vendor_ruby/2.5.0
~/.rbenv/versions/2.5.0/lib/ruby/vendor_ruby/2.5.0/x86_64-linux
~/.rbenv/versions/2.5.0/lib/ruby/vendor_ruby
~/.rbenv/versions/2.5.0/lib/ruby/2.5.0
~/.rbenv/versions/2.5.0/lib/ruby/2.5.0/x86_64-linux
~/.local/share/JetBrains/Toolbox/apps/RubyMine/ch-0/182.4505.55/rubystubs25
Sdk Gem paths:
~/.gem/ruby/2.5.0/gems
~/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/bundler/gems
~/.bundle/ruby/2.5.0/gems
~/.bundle/ruby/2.5.0/bundler/gems
~/.gem/ruby/2.5.0/bundler/gems
~/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems
(full list of gems used for project)
So I think that last bit - "Sdk Gem paths" - might be the problem point, but I don't see any way to configure it.
I'm also already aware of the YouTrack issue "Rubymine 2018.2 release does not take $GEM_HOME environment variable" and don't think it's quite what's happening here. It also claims to be fixed in 2018.3 EAP1, so I installed 2018.3 EAP7 but am still seeing this problem.
I got things working! By signing out and back in. :facepalm:
To be specific, I think the key steps were
Move the $(rbenv init -) step from my .zshrc up to my .zshenv and/or to .profile
Signing out and back in.
The key insight was noticing that ~/.rbenv/shims was missing from the RubyMine Gem Environment despite showing up in both interactive and login shells (in and out of RubyMine), and realizing that while new shells were picking up my .profile changes, RubyMine itself was probably inheriting its environment variables from my session and I'd need to log out/in to to pick up the changes.
I now see ~/.rbenv/shims in my RubyMine Gem Environment, and both the Bundler Install command and my run configurations are working again.
Thank you Casper for pointing me in the right direction!
Been where you are before a bunch of times.
Under the list of scripts you can run, click "Edit Configurations". Should be in the main toolbar.
Double check that you have "Run the script in context of bundle (bundle exec)" checked on the bundler tab. This is SUPER important and is not checked by default. Make sure you check for any rake, rails or irb configurations.
Keep in mind that the run configuration is where you can override the settings for the project. It will create all kinds of problems if this is not set appropriately.
Hope this helps! Bit me a bunch of times.
/gems/htmlentities-4.3.2/lib/htmlentities/mappings/expanded.rb:465: warning: duplicated key at line 466 ignored: "inodot"
/gems/ruby-2.2.0/gems/fog-core-1.25.0/lib/fog/core/collection.rb:144: warning: circular argument reference - filters
The obvious suspicion is that these gems don't like ruby 2.2.0, but things seem to be working
Should I fear future, imminent failures, or has these gems just haven't caught up yet?
Both problems were solved in newer versions of these gems.
If I am depending on gems like that, I usually wait a little bit before switching the project to the latest and greatest ruby in production. Gems need time to get compatible with all the changes.
I to have like this error when install redmine 3.2:
/usr/lib/ruby/gems/2.3.0/gems/htmlentities-4.3.1/lib/htmlentities/mappings/expanded.rb:465: warning: key "inodot" is duplicated and overwritten on line 466
All is simple - just edit this file and remove duplicated line!)
But sometimes need just check your htmlentities version and remove not needed
gem list htmlentities
gem uninstall htmlentities -v '4.x.x'
My System Config: Win 8.1 + SQL 2016 Expr SP1 + Redmine DB (type SQL 2012 CS AI) + Redmine 3.3.1 + Ruby 2.3.3 + devkit + ImageMagick-6.9.6-8-Q16-HDRI-x64-dll (ImageMagick-7.0.3 Not working!)
Fix issue with htmlentities-4.3.1 "key inodot"
gem install htmlentities -v '4.3.4'
gem uninstall htmlentities -v '4.3.1'
Fix issue with error load "tiny_tds"
gem install tiny_tds -v '1.0.5'
gem uninstall tiny_tds -v '0.6.2'
Change all dependencies in Gemfile & Gemfile.lock from old version to new installed.
All other commands from Installing Redmine Guide Site.
Result:
c:\inetpub\redmine>bundle exec rake db:migrate
migrating
add_column(:roles, :settings, :text)
-> 0.0019s
-> -1 rows
AddRolesSettings: migrated (0.0027s)
c:\inetpub\redmine>set REDMINE_LANG=ru
c:\inetpub\redmine>bundle exec rake redmine:load_default_data
Default configuration data loaded.
c:\inetpub\redmine>bundle exec rails server webrick -e production
=> Booting WEBrick
=> Rails 4.2.7.1 application starting in production on http://localhost:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-12-13 15:14:25] INFO WEBrick 1.3.1
[2016-12-13 15:14:25] INFO ruby 2.3.3 (2016-11-21) [x64-mingw32]
[2016-12-13 15:14:25] INFO WEBrick::HTTPServer#start: pid=4468 port=3000
[2016-12-13 16:02:58] INFO going to shutdown ...
[2016-12-13 16:02:58] INFO WEBrick::HTTPServer#start done.
Exiting`enter code here`
gem uninstall htmlentities -v '4.3.2'
gem install htmlentities -v '4.3.4'
When I run bundle exec guard after upgrading to Ruby 2.1.1, I get this:
Frame number: 0/1
before_session hook failed: NotImplementedError: NotImplementedError
/home/eric/.rbenv/versions/2.1.1/lib/ruby/gems/2.1.0/gems/interception-0.4/lib/interception.rb:122:in `start'
(see _pry_.hooks.errors to debug)
How can I resolve this?
The officially released version of the interception gem you are using (0.4) checks for MRI Ruby 2.1 via the following method:
# lib/interception.rb
def self.ruby_21?
RUBY_VERSION == '2.1.0' && RUBY_ENGINE == 'ruby'
end
Obviously, this fails for Ruby 2.1.1
This is corrected in the master branch (https://github.com/ConradIrwin/interception), but the correction has not been released to RubyGems (as of 3/5/14).
Edit:
As of 3/6/14, interception v0.5 has been released to RubyGems and fixes this issue. Verify the interception gem is not set to v0.4 or lower in your Gemfile, then run bundle update interception.
I've tried to follow various online references for jruby debugger but it is not working.
I've tried following: first change to root (does not work as normal user) then:
jruby -S gem install ruby-debug-base
jruby -S gem install ruby-debug-base
But then the following command fails:
jruby --debug -S rdebug ./classifier-wf.rb
Gem::LoadError: Could not find columnize (>= 0.1) amongst [jdbc-mysql-5.1.24, rake-10.0.3, ruby-debug-0.10.4, ruby-debug-base-0.10.4-java]
to_specs at /opt/jruby-1.7.3/lib/ruby/shared/rubygems/dependency.rb:247
activate_dependencies at /opt/jruby-1.7.3/lib/ruby/shared/rubygems/specification.rb:777
each at org/jruby/RubyArray.java:1613
activate_dependencies at /opt/jruby-1.7.3/lib/ruby/shared/rubygems/specification.rb:766
activate at /opt/jruby-1.7.3/lib/ruby/shared/rubygems/specification.rb:750
gem at /opt/jruby-1.7.3/lib/ruby/shared/rubygems.rb:1232
(root) at /opt/jruby-1.7.3/bin/rdebug:22
I am running jruby 1.7.3. thanks.
Use Pry instead of other debugger gems, soon you'll be addicted to it.
(Update: Problem caused by zsh, see accepted answer)
Long ago, I followed this great guide to using Rbenv with bundler https://gist.github.com/1384279 and all was well in Ruby Land. (I installed it correctly)
Bundler gem is installed globally for the current ruby version. All gems for each project are bundle installed from their respective gemfiles.
I am attempting to install Zeus globally (like how bundler is installed globally) rather than adding it to the gemfile of each project.
joe#computer:~/some_project
> rbenv versions
1.9.3-p194
* 1.9.3-p327-perf (set by /Users/joe/some_project/.rbenv-version)
joe#computer:~/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems
> ls -a
. method_source-0.7.1 zeus-0.13.1
.. rake-0.9.2.2
bundler-1.2.0.rc.2 rdoc-3.9.4
I have succeeded, as you can see zeus is installed globally along with bundler... however:
joe#computer:~/some_project
> rbenv rehash
joe#computer:~/some_project
> zeus init
Users/joe/.rbenv/versions/1.9.3-p327-perf/lib/ruby/gems/1.9.1/gems/bundler-1.2.0.rc.2/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': zeus is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/joe/.rbenv/versions/1.9.3-p327-perf/bin/zeus:22:in `<main>'
As far as I can discern, zeus is being sought as if it is bundle installed, but its not bundle installed its globally installed.
How do I get the shell to look at the global gems before the bundled gems?
If I got it right and you have the same problem with me and you are also running zsh, then this problem is that oh-my-zsh automatically wraps some commands using bundler if you have the bundler plugin installed.
See: https://github.com/robbyrussell/oh-my-zsh/pull/1507
https://github.com/robbyrussell/oh-my-zsh/pull/1138
https://github.com/heroku/heroku/issues/173
EDIT: This has been fixed in oh-my-zsh
If you do have this problem with oh-my-zsh and for whatever reason you haven't updated, you could just prepend zeus with a backslash, for example:
% \zeus start
% \zeus g model Post title content:text
% \zeus rake db:migrate
What the backslash does is runs the command overriding any aliases. See this section on Wikipedia http://en.wikipedia.org/wiki/Alias_(command)#Overriding_aliases