Hart1´s Ruby Tutorial - Subl Gemfile - failed with error -43 - ruby

I am struggeling my way through Hart1's Ruby Tutorial, and I can't get past this point; whenever I execute the subl Gemfile command, I get the following error:
FSPathMakeRef(/Applications/Sublime Text 2.app) failed with error -43.
Can someone help me??

To echo what R_G said - you should definitely include more information about your environment to get better help.
What's happening here could be that you don't have sublime text installed in your applications (if you downloaded on a mac, you have to drag it into the applications folder - Or you don't have the 'subl' command set up in your command line. I never got subl as a command to work from my command line when I was working on a windows computer....
Here are instructions on how to do these things - if you are working from a Mac. http://www.sublimetext.com/docs/2/osx_command_line.html
What it's trying to get you to do is just open the gemfile with sublime text - so since you are just beginning -- just do that. Manually open the sublime text application and then manually find the gem file in your application folders and open it.

Related

Cocoapods sudo-less installation

Hi I follow this guideline for sudo-less installation https://guides.cocoapods.org/using/getting-started.html and I stuck on /Users/eloy/.gem/ruby/2.0.0/bin/pod install
Terminal says [!] No Podfile found in the project directory.
Command gem which cocoapods correctly shows path to cocoapds so I guess installation succeed. I tried changing paths in .profile file but it's not a problem. Please give me some ideas.
I followed the same guidelines for sudo-less installation, and I had the same results and issues. I'm very new to all of this, so take this answer with a healthy dose of skepticism unless someone more experienced confirms it.
After some poking around on google, I stumbled upon this article.
Following these instructions resolved my issues, so I hope they help you as well.
EDIT: This temporarily adds CocoaPods to your path. I am using a Mac that uses a zsh shell for the terminal.app. I'm not sure what shell you have, but for Macs you'll need to edit your .zshrc file (or create one because you will not have a .zshrc file on your Mac if you have not created one yourself already). I found this answer that shows how to create the .zshrc file through the terminal. You can find the .zshrc file you have created by navigating to Macintosh HD > Users > [INSERT_USERNAME] and pressing "cmd + shift + ." to show hidden files. Scroll down until you see the .zshrc file, open it with a text editor, and input the code from the first page I linked. Save it and exit. Now you should always have CocoaPods in your path every time you open up the terminal!
Probably an easier way to do this, but it worked for me.

Ruby Shoes, OS X always has error when opening app once packaged

Using Shoes (v3.2) to 'Package my App'. Package directory with start script.
Including full copy of shoes.
Opening the packaged app e.g. double click icon, the error console opens:
No such file or directory # rb_sysopen -
/private/var/folders/20/9wqryt1n76s1f0b9mpq500nc0000gp/T/shoes-upload-gui.40507/upload-gui.shy
Visiting the temp directory the shy file is not packaged as part of that directory.
I have tried
putting the shy into the directory then packaging again works, but the package is now twice as big
creating a dummy (zero byte) .shy file in the directory and packaging it. This fails with a different error (seems to be trying to unpack the shy and it fails to open - no surprise)
run the app from command line via shoes-launch e.g /Applications/Shoes.app/Contents/MacOS/shoes-launch rubystart.rb console log error never appears
i have noticed that if run shoes-launch with an additional argument e.g /Applications/Shoes.app/Contents/MacOS/shoes-launch rubystart.rb blah then i get the same No such file or directory # rb_sysopen - blah error for that file
so it seems like the ruby-shoes packager is trying to call shoes-launch with additional command line parameters (its own shy file?)
anyone come across or fixed this e.g. not needed to put the full shy package within itself?
thanks
Ben
I never fixed the shoes packager. I had to manipulate the final xxx.app as follows
remove the .shy file
copy over my ruby files
ensure gems copied over into lib/gems/... (Note i had issues with gems being picked up via rvm anyhow )
edit XXX-launch script removing .shy file with my own ruby file
and it all works. there is no error when opening the app.
conclusion: something in the .shy file perhaps? shoes is being upgraded to shoes 4 anyhow, and all this was on shoes 3.
It seems to happen only when trying to package the whole directory.
(Which also requires creation of a .shy file)
My workaround would be: Package a single file and copy the rest into the bundled application.
I only tryed this on MacOSX and the path inside the App would be "Contents/MacOS/".
After doing this everything worked fine, my app is very simple though.

Loading .rb files in Mac OS IRB

I'm just staring out with Ruby. I followed a tutorial to set up Ruby environment on my Mac OS. Then, I created a file named 'personal_chef.rb' in Sublime Text and saved it to a folder I created. Next went to IRB and tried "load 'personal_chef.rb'" and got the error:
-bash: load: command not found
I think it might have to do with how I switched my PATH when installing a new version of git during Environment setup. (I did that by following their instructions and typing: 'echo 'export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"' >> ~/.bash_profile').
Can someone please help explain what is happening and how I can fix it? Basically I want to be able to create a file in Sublime Text, save it, then load it in IRB.
(I am running Mac OS 10.7.5, using Sublime Text 2.0.2 and using Terminal.app for IRB).
Thanks!
This is how you load the file:
First, make sure you enter the irb command from within the same directory you saved 'personal_chef.rb'.
This means that if you saved it to your desktop, you would type ~/desktop
You'll know you're in irb if your command line beings with irb(main)
Next simply type load 'personal_chef.rb'
If you successfully loaded the file the load method will return true.

RubyTest Sublime Text 2 not working on Windows 7

I've been messing around with this for well over an hour and still can't get RubyTest working within Sublime Text 2. Each time that I attempt to run a test I get a simple message that " 'rspec' is not recognized as an internal or external command, operable program or batch file."
I tried both the clone from github method of installing RubyTest, as well as via Package Installer with the same results. I'm launching Sublime Text 2 via "subl ." from my application's directory.
I know I'm just missing something simple, but all of the fixes I've found on the web are specific to non-Windows environments and I haven't been able to adapt the answers to my circumstances.
I am NOT using pik or any other Ruby version manager.
What am I doing wrong?
Figured it out, needed to prefix "bundle exec" to the "rspec" command in my User - RubyTest.sublime-settings file to get it to work. – Rob Jan 29 '13 at 20:26

RubyTest in Sublime Text 2

I am trying to get RubyTest to work in Sublime Text 2. I followed the Instruction on the Github Readme and get the following error. Does anyone know how I could fix this?
/bin/sh: rspec: command not found
To get this to work you only need to change one setting in the RubyTest package in sb2.
If you are using rvm, your rspec gem is installed through rvm and is not found in /bin/sh
So you need to set the RubyTest package for Sublime Text 2 to automatically check for your rvm environment variables.
What to change:
1) In Sublime Text 2, go to Preferences|Browse Packages. This will open up your packages directory.
2) Open the 'RubyTest' directory and look for the file 'RubyTest.sublime-settings'.
3) find the line that says:
"check_for_rvm": false,
and change it to:
"check_for_rvm": true,
save the change.
4) That's it. It should now work.
Good Luck
This worked for me:
If you're using RVM, open a project with command line from the project's folder:
subl .
Then, it'll hook the ruby version and gems.
This is most likely due to using RVM. What is the output of
which rspec
on your command line?
Also of note, just because you've included rspec-rails in a Gemfile, does not mean that 'rspec' is an executable program that your system knows about.
You can edit the RubyTest.sublime.settings to refer to your particular path to the rspec executable and it should work.
Unfortunately, this has the nasty side effect of being tied to one particular version of Ruby. If you're using RVM to switch between versions, you'll have to update your sublime.settings.
One work around, is to run Sublime from the command line.
Running Sublime Text 2(2165) with RubyTest plugin. Ruby and Gems managed with rbenv (0.3.0).
First attempt to use RubyTest gave the following error:
/bin/sh: rspec: command not found
From the command line I ran
which rspec
and it returned no results.
After some digging, I read that bundle install does not put the executables in your $PATH.
Alternative executable paths not picked up by shims sometimes
In order to use the executible outside the app, I had to delete the gem installed by bundler and then install it manually.
gem uninstall rspec
gem install rspec
followed by
rbenv rehash (Note you will need to run bundle inside your app so it updates the location of the gem)
This had to be performed for each version of ruby I have under rbenv control.
Now when I run
which rspec
it is found in the path and RubyTest is able to grab it without any problems.
fwiw, I had to repeat the steps for cucumber as well. To use all of RubyTests' features, ruby, cucumber and rspec executables need to be in your $PATH (for rbenv it is ~/.rbenv/shims/).
Try change the path to usr/local/bin/
I wrote a post on Sublime Text Build Scripts which should show you how to do this.
http://wesbos.com/sublime-text-build-scripts/
Same issue for me. With rspec 1.3.2 what I just did to fix it is to edit the RubyTest.sublime.settings file in the plugin folder, changing the "ruby_rspec_exec" key from:
"ruby_rspec_exec": "rspec"
to
"ruby_rspec_exec": "spec"
It really depends on the location where you have your rspec executable file...
I had the same problem after installing RubyTest by cloning from the repo. I simply uninstalled and reinstalled the package inside Sublime using Package Control, then everything worked fine.
You can see a summary of this issue here: https://github.com/maltize/sublime-text-2-ruby-tests/issues/36
Essentially, what Jim said was correct, you're running RVM or some other ruby vm manager that similarly monkeys with your PATH. Following the directions from this issue I did the following:
Install the binaries in my project
bundle install --binstubs
Add the path to my .bashrc and source it
echo 'export PATH="./bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Open the sublime project from the command line (so that PATH is available in Sublime Text 2)
subl .
The following steps worked for me (I encountered the same error as OP):
Install the RubyTest plugin through the package control manager.
Note* If you don't have the package manager installed - I highly recommend it for managing sublime plugins - more info here.
Be sure to add the code here to your RubyTest.sublime-settings file.
This file can be found at (from the menu): Preferences -> Package settings -> RubyTest -> Settings User
Save file, close Sublime and restart Sublime from the terminal in your project's folder using (so PATH is available in Sublime): subl .
No, you don't need to change paths, run sublime from command line etc.
If you are using RVM, you only have to do this:
Go to Sublime Text 2, go to
preferances-> package settings -> RubyTests
and pick settings-user or settings-default (depending what you are using) and change line:
"run_rspec_command": "rspec {relative_path}"
to
"run_rspec_command": "bundle exec rspec {relative_path}"
And so forth - add bundle exec to all commands
I spent many hours struggling with this same problem! I could not get rspec to run within Sublime Text 2, using the Michael Hartl "Ruby on Rails Tutorial." It kept saying:
/bin/sh: rspec: command not found
I finally realized that the RubyTest package (https://github.com/maltize/sublime-text-2-ruby-tests) was looking in the WRONG PLACE for my RVM!
On my Mac, the path for RubyTest is /Library/Application Support/Sublime Text 2/Packages/Ruby Test
First, to make RubyTest seek the RVM, I changed the parameter in RubyTest.sublime-settings from
"check_for_rvm": false, to "check_for_rvm": true,
Then I dug into the Python code of run_ruby_test.py: https://github.com/maltize/sublime-text-2-ruby-tests/blob/master/run_ruby_test.py
At line 151, inside class BaseRubyTask, it had the wrong path for my RVM:
rvm_cmd = os.path.expanduser('~/.rvm/bin/rvm-auto-ruby')
I changed it to the full correct path: rvm_cmd = os.path.expanduser('/usr/local/rvm/bin/rvm-auto-ruby')
If this is not your path, find the correct path by typing
$ which rvm-auto-ruby and substitute that instead.
After saving run_ruby_test.py, I went to Terminal, cd to my Rails application directory, and ran spork
Finally, I opened static_pages_spec.rb in Sublime Text 2. Now all the tests work from it!
I'm using rbenv and found that adding the following to my .bashrc did the trick
/Users/user/.rbenv/shims/rspec

Resources