GithubHelp home page GithubHelp logo

Comments (9)

Dangeranger avatar Dangeranger commented on August 11, 2024 1

Found a fix, solution below:

Solution:

Within my .zshrc I had initialized rbenv with

# Within ~/.zshrc

# Setup rbenv shims, completion, and path
eval "$(rbenv init -)"

After moving this into my ~/.zshenv instead, restarting my shell, and restarting Spacemacs, rspec-mode found the correct Ruby version managed by rbenv and invoked the tests as expected.

# Within ~/.zshenv

## Default PATH foundation
PATH=/usr/local/bin:/usr/local/sbin:...lots-more-dirs-here...$PATH;
export PATH

# Setup rbenv shims, completion, and path
eval "$(rbenv init -)"

from rspec-mode.

dgutov avatar dgutov commented on August 11, 2024

Try https://github.com/purcell/exec-path-from-shell, maybe.

This problem is probably not rspec-mode-specific.

from rspec-mode.

Dangeranger avatar Dangeranger commented on August 11, 2024

@dgutov Yeah maybe that's possible, I just invoked RSpec from within a Dired buffer by using shell-command with bin/rspecand received

/Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- bundler (LoadError)
	from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_require.rb:54:in `require'
	from /Users/username/Dev/projects/project/bin/spring:8:in `<top (required)>'
	from bin/rspec:3:in `load'
	from bin/rspec:3:in `<main>'

from rspec-mode.

Dangeranger avatar Dangeranger commented on August 11, 2024

Looks like that package is included within the base packages.

https://github.com/syl20bnr/spacemacs/blob/8e1af145480d53e8d32cdff2c83291889903164b/layers/+distributions/spacemacs-base/packages.el#L30

And the function is defined within the packages.el

(defun spacemacs-base/init-exec-path-from-shell ()
  (use-package exec-path-from-shell
    :init (when (or (spacemacs/system-is-mac)
                    (spacemacs/system-is-linux)
                    (memq window-system '(x)))
            (exec-path-from-shell-initialize))))

from rspec-mode.

Dangeranger avatar Dangeranger commented on August 11, 2024

Created new issue in Spacemacs syl20bnr/spacemacs#9512

from rspec-mode.

Dangeranger avatar Dangeranger commented on August 11, 2024

@dgutov So I've checked the ruby version used by other packages, specifically inf-ruby-console-rails and found that when using the console from within Emacs, correct Ruby binary and versions are used. rspec-mode seems to be the only package NOT using the rbenv binaries.

For example, M-x ruby-switch-to-inf

Error message when starting an interactive ruby console session from Emacs. Console still starts anyway.

mapcar: Wrong type argument: stringp, ((path . "/Users/username/Dev/projects/project-name/lib"))

Resulting ruby version within the inf-ruby interactive session.

Running via Spring preloader in process 89593
Loading development environment (Rails 4.2.7.1)
[1] pry(main)> => "robe on 49355"
[2] pry(main)> RUBY_VERSION
=> "2.2.3"
[3] pry(main)> 

Results of checking the environment variables from within Emacs

// M-x getenv PATH

=> /Users/username/.rbenv/bin:/Users/username/.rbenv/shims:/Users/mansfield/.exenv/shims: ... rest of path follows

// M-x describe-variable exec-path 

=> exec-path is a variable defined in ‘C source code’.
Its value is
("/Users/username/.rbenv/bin" "/Users/username/.rbenv/shims" ... rest of path)

Original value was 
("/Users/username/.rbenv/bin" "/Users/username/.rbenv/shims" ... rest of path)

  This variable may be risky if used as a file-local variable.

Documentation:
List of directories to search programs to run in subprocesses.
Each element is a string (directory name) or nil (try default directory).

By default the last element of this list is ‘exec-directory’. The
last element is not always used, for example in shell completion
(‘shell-dynamic-complete-command’).

You can customize this variable.

from rspec-mode.

dgutov avatar dgutov commented on August 11, 2024

Ouch, zsh.

I just put the rbenv config into ~/.profile. On Ubuntu, that is.

from rspec-mode.

Dangeranger avatar Dangeranger commented on August 11, 2024

It's my fault for not paying attention to how Emacs invokes your environment as it boots. The strange part is that non of the other packages exhibit this problem.
🤷‍♂️

from rspec-mode.

dgutov avatar dgutov commented on August 11, 2024

If we're talking about inf-ruby, then Spring might be calling the shell, and perform initialization doing that... IDK.

from rspec-mode.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.