Normally I run the non-graphical version of Emacs in iTerm and switch to a non-Emacs tab to run rspecs and cucumbers at the command line. The other day, since I have feature-mode installed, I typed C-c , v
in a feature file to run the cucumber features. The start of the compilation buffer of the results showed:
-*- mode: compilation; default-directory: "~/code/my-project/features/" -*- Compilation started at Sat Feb 28 00:24:30 rake cucumber CUCUMBER_OPTS="" FEATURE="/Users/seanmiller/code/my-project/features/smoke.feature" (in /Users/seanmiller/code/my-project) rake aborted! undefined method `result' for #<TypeError:0x007fa8ca0f51c0> /Users/seanmiller/.rvm/gems/ruby-1.9.3-p551@my-project/gems/activerecord-3.2.13/lib/active_record/connection_adapters/postgresql_adapter.rb:1147:in `translate_exception'
with a long stack trace mostly in the activerecord adapters.
The third line (starting “rake cucumber…”) is the command that was run, so we can type M-x eshell
to get a shell within Emacs, paste in the line and run it, and there the cucumbers run without error. We can also type M-x compile
to get a compile command prompt directly, paste in the line again, and we end up with the error we started with. The compile command prompt and the Emacs shell are behaving differently.
What if we run echo $PATH
in both? The shell path starts with several rvm-related directories. The compile prompt path starts with /usr/bin and the rvm-related directories are nearer the end.
That might well do it, but what is causing it? The manual for the compilation shell notes that it brings up a noninteractive shell. The manual for zsh notes that while ~/.zshenv
is run for almost every zsh, ~/.zshrc
is run only for interactive shells. So if I get the latest version of the rvm dotfiles via rvm get stable --auto-dotfiles
and move the two lines that show up in ~/.profile
not to my ~/.zshrc
file but to my ~/.zshenv
file, and then restart Emacs, I can run the cukes from M-x compile
or C-c , v
and they run cleanly.
What’s more, in the compilation buffer of the test results, the comments referring to the line numbers of feature and step definition files are live links: press enter on them to jump to the lines of the code files. Maybe there is a point to running them in Emacs after all…