Why won't macvim always use ruby 1.9.3? - ruby

I have installed yadr dotfiles, a set of vim, ruby, etc plugins.
I have the following line of Ruby code in a file foo.rb:
foo: bar
Note I used the ruby 1.9.3 syntax for symbol assignment/definition.
When I start macvim from command line using mvim foo.rb and save that file, everything works fine.
However, when I open macvim using open -a macvim and navigate to and open foo.rb, when I try to save the file I get a ruby-vim syntax error on foo: bar. When I change it to :foo => bar I don't get syntax errors.
Using open -a macvim to open macvim, and then entering :!ruby -v prints ruby 1.8.7
Using mvim . to open macvim, and then entering :!ruby -v prints ruby 1.9.3
Depending on how I open macvim, I get a different version of Ruby. How do I ensure that macvim always uses ruby 1.9.3 to evaluate my ruby code?
Thanks

It took me awhile to find a fix, but the issue is caused by MacVim not loading zsh the same way Terminal loads zsh.
The fix is easy enough and can be placed into your zshrc. See a commit from my dotfiles:
https://github.com/simeonwillbanks/dotfiles/commit/e0e19cfeff13f8bc99d8164217ddd84c6d7f9529
The commit references a full explanation which can be found here:
http://vim.1045645.n5.nabble.com/MacVim-and-PATH-tt3388705.html#a3392363
Hope this helps!

Related

I can't run my Ruby program and I see errors in the terminal. I can't find the program

Good afternoon! I have a problem with Ruby. I downloaded this program from the official site https://www.ruby-lang.org/en/downloads/ on Fedora without any problems (using the command via the terminal). However, I cannot use the 'irb' command in the terminal to run Ruby on Linux as described here https://www.ruby-lang.org/en/documentation/quickstart/. Therefore, I cannot learn the Ruby programming language.Command 'irb' not found
I tried my best to run Ruby in other ways. One of them, as is customary in Fedora, is to write the name of the program in the terminal. But it opens a folder in which, I assume, Ruby is located (I can't find the folder itself either in Files or via the 'cd' command in the terminal). I kind of can open this folder in the terminal, but I can't find it in Files.
Oh, by the way, the 'irb' command doesn't work there. Only some real command for a program like this one will work: irb(main):001:0> "Hello World" (from https://www.ruby-lang.org/en/documentation/quickstart/). The program is and is not at the same time
Move on. I made a text document, wrote irb(main):001:0> "Hello World" in it (as written in "Ruby in Twenty Minutes"), and saved the file as hello.rb . Opened the hello.rb file path through the terminal and wrote 'ruby hello.rb' (without quotes, of course). Result: syntax error. hello.rb file Tried to open hello.rb via ruby in terminal
Oh yeah, I almost forgot: when I tried to open hello.rb in Files through another application, there was no Ruby script in the list (ruby or irb or at least something through which one could open a .rb file). No program for .rb format
I hope I have explained the problem in sufficient detail and clearly. And I hope for your help and understanding! In any case, good mood to you!
On Fedora & CentOS, the Ruby installation is split into many smaller packages. If you want to run irb, you'll also have to install the ruby-irb package using dnf install ruby-irb.

Get Vim on Mac terminal to copy to the clipboard

I'm using Vim on a Mac, installed via homebrew, version 8.0.
Vim --version shows +clipboard, and -xterm_clipboard.
I've tried
set clipboard=unnamed
in .vimrc
But I cannot get yanks to go on to the system clipboard. What do I do?
It should "just work" on MacVim. One of the reasons I'm using it is for its OSX integration, including clipboard.
brew install macvim
mvim defaults to graphical mode. To run it in terminal mode:
mvim -v
In the past, I had an alias for vim -> mvim -v which handles most cases. These days I use the following script in ~/bin/vim, which is in my $PATH:
#!/bin/bash
mvim -v "$#"
seems like something is overriding your clipboard setting after loading your vimrc.
try :verbose set clipboard?. It should tell you when and where this variable was last set.
This guide gives you a bunch of hints on what to do to figure out what's going on and fix the problem

rvm-installed ruby: runs in terminal fine, not anywhere else

I have installed Ruby via RVM on Linux Mint 11. It seems to have installed fine: when I enter type rvm | head -1, I get "rvm is a function" back. Entering ruby -v gives me 1.9.2p290. I can run ruby scripts from the bash terminal window fine. However, when I try to run the same scripts from say gvim (I've got a shortcut mapped to "ruby ") or geany or gedit (ditto), I get "ruby: command not found" (in gvim) or "ruby: not found" (in geany or gedit).
Here's more information: "which ruby" gives me: $HOME/.rvm/rubies/ruby-1.9.2-p290/bin/ruby. $HOME/.rvm/rubies/ruby-1.9.2-p290/bin is in my path in my .bashrc. On another Linux Mint 11 machine, where all works fine, "which ruby" gives me $HOME/.rvm/bin/ruby. Also, on the machine where all is fine, I have a $HOME/bin folder that I don't know where it came from, but was created the same day as my .rvm folder. It contains among other things, links to shell scripts in the $HOME/.rvm/wrappers folder.
I had same problem, you should try making shell login. To make so use the command "bash -l" instead of simply "bash". In geany you can find where to change it in edit->preferences->terminal->shell
I think you dont have your current ruby set as system default. try running this command:
rvm use 1.9.2 --default

ruby irb on windows using gitbash shell - can't use arrow keys to modify command input?

when I do rails console my git bash shell permits me to use up arrow to recall commands, and use left/right arrows to modify the text I'm entering
when I run irb the shell ignores backspace and arrow keys
I'm not sure why the arrow keys would work fine in the shell for rails console but not when running irb?
As I just wrote in the related Backspace and arrow keys aren't working in IRB(Git Bash console) on windows machine:
running irb with --noreadline solved this problem for me:
irb --noreadline
What operating system are you running? You may need install the GNU Readline Library and reinstall ruby.
Doing the following command fixed the problem for me on Windows
gem install wirble win32console
As documented here https://groups.google.com/forum/#!topic/rubyinstaller/HgswOz1T-eE, use the below command/alias:
alias irb="ruby -S irb"

TextMate, rvm and TM_RUBY

In the TextMate RVM instructions the text it says to set TM_RUBY to /Users/wayne/.rvm/bin/textmate_ruby and in the image it shows it set to rvm-auto-ruby. I decided to set it to rvm-auto-ruby thinking that it would use RVM's default Ruby version.
When running Command R in the RSpec.bundle having TM_RUBY set to rvm-auto-ruby will result in a load error. When you set it to textmate_ruby it works.
The only problem here is that TextMate doesn't always use the default version of Ruby since it's hardcoded in that file.
/Users/jspooner/.rvm/bin/textmate_ruby:
#!/usr/bin/env bash
if [[ -s "/Users/jspooner/.rvm/environments/ruby-1.9.2-head" ]] ; then
source "/Users/jspooner/.rvm/environments/ruby-1.9.2-head"
exec ruby "$#"
else
echo "ERROR: Missing RVM environment file: '/Users/jspooner/.rvm/environments/ruby-1.9.2-head'" >&2
exit 1
fi
So two questions:
What should TM_RUBY=rvm-auto-ruby actually do?
Is there a way to have TextMate use the RVM default?
Setting TM_RUBY to your-path/rvm-auto-ruby
http://rvm.io/integration/textmate/
should load whatever ruby and gemset is indicated in the .rvmrc file located in the project and if none default to rvm default. I just got this working and it is very smooth. I did need to get the latest version of rvm
rvm get head
to make it work and restart Textmate. Hope that helps.
See your other, similar, question Rspec bundle is broken in TextMate and rvm.
To help others chasing this same issue, the solution seems to be at: RVM / Textmate doesnt recognize .rvmrc Options.
Basically you replace the ~/.rvm/bin/textmate_ruby soft link with a file. This is what I did:
cd ~/.rvm/bin
mv textmate_ruby old.textmate_ruby
Create a shell script called textmate_ruby in the same directory to replace the soft-link, using the following contents:
!/usr/bin/env sh
source ~/.rvm/scripts/rvm
cd .
exec ruby "$#"
chmod +x textmate_ruby
Before doing this change I'd see my system Ruby's version (1.8.7) displayed if I did CMD+R to run the following script in TextMate:
puts RUBY_VERSION
Evaluating the script using CMD+CNTRL+SHIFT+E gave me 1.9.2.
After switching to use that script both point to Ruby 1.9.2, so at least there's some consistency now. I don't see TextMate tracking my currently set RVM Ruby version yet; Instead it's using the default version set in RVM: rvm use 1.9.2 --default. This is still a step forward because I can control which Ruby TextMate uses by adjusting my --default.
If you decide you want to revert later, just rename, or delete, the script and reverse step 2 above.

Resources