asok / projectile-rails

Emacs Rails mode based on projectile
258 stars 59 forks source link

Cannot run bundle #158

Closed bnsv closed 3 years ago

bnsv commented 3 years ago

Hi. When I try to run console or server it wont work, it throws:

-*- mode: projectile-rails-server; default-directory: "~/latihan/rubee/anoto/rel604/" -*-
Projectile Rails Server started at Mon Oct 25 00:41:40

bundle exec rails server
Traceback (most recent call last):
    2: from /usr/local/bin/bundle:23:in `<main>'
    1: from /usr/local/lib/site_ruby/2.5.0/rubygems.rb:308:in `activate_bin_path'
/usr/local/lib/site_ruby/2.5.0/rubygems.rb:289:in `find_spec_for_exe': can't find gem bundler (>= 0.a) with executable bundle (Gem::GemNotFoundException)

Projectile Rails Server exited abnormally with code 1 at Mon Oct 25 00:41:40

Btw, bundler.el recognize the bundler gem (inside emacs) and return the version correctly. Also when I run bundle or server in terminal everything is working well. I already have latest bundler installed but 'projectile-rails' wont recognize it. I thought it was about different PATH approach betwen shell and emacs so I also set this in my init.el but stiil not works.

;; https://github.com/purcell/exec-path-from-shell
(when (memq window-system '(mac ns x))
  (exec-path-from-shell-initialize))
(when (daemonp)
  (exec-path-from-shell-initialize))
purcell commented 3 years ago

And what happens if you use M-! to run bundle exec rails server?

bnsv commented 3 years ago

It throws the same error ie (Gem::GemNotFoundException). I also make sure to bundle exec rails server via terminal and its working well.

bnsv commented 3 years ago

But wait, I try the bundler.el again using M-x bundle-install it throws the same error. when i do M-x bundle-version it return 2.1.4. I dont have bundler 2.1.4 anymore, I already uninstalled it (gem cleanup bundler).

$ gem list bundler
*** LOCAL GEMS ***
bundler (default: 2.2.29)

When I M-x bundle-gemfile to some of my project gemfile, then bundle install it. it throws:

Your Ruby version is 2.5.1, but your Gemfile specified 2.6.6

I dont even have Ruby v2.5.1. Mine is only 2.6.6 & system. and it is true that ruby is set to 2.6.6 in the project gemfile (v2.5.1 wont work with Rails 6).

$ rbenv versions
  system
* 2.6.6 (set by ~/latihan/rubee/anoto/rel604/.ruby-version)

Now, when I do run server and also (M-x bundle exec rails s) the error is also change to:

-*- mode: projectile-rails-server; default-directory: "~/latihan/rubee/anoto/rel604/" -*-
Projectile Rails Server started at Mon Oct 25 16:40:17

bundle exec rails server
Your Ruby version is 2.5.1, but your Gemfile specified 2.6.6

Projectile Rails Server exited abnormally with code 18 at Mon Oct 25 16:40:18
purcell commented 3 years ago

Sounds like Emacs only sees the system Ruby. So probably rbenv is setting the PATH to include the 2.6.6 version, but your rbenv setup isn't getting invoked when Emacs runs processes. This could be for various reasons, e.g. perhaps Emacs uses a different shell from your terminal, so it doesn't see the same startup files. You can use C-h v to look at exec-path, and if you set exec-path-from-shell-debug to t then run exec-path-from-shell-initialize, you'll get some diagnostic info in your *Messages* buffer.

purcell commented 3 years ago

None of this is related to projectile-rails, though, just to be clear.

bnsv commented 3 years ago

Alright then. Thank a lot Mr Purcell for your helping instructions and I apologize for misjudging which package or what causing the error simply because apparently projectile-rails throws it. I will close the issue now. Thank you for your time.