Ruby on Rails - bin files shebang causing issues (Mac) - ruby-on-rails

So for the files in the /bin directory of a normal rails installation (bin/rails, bin/rake, bin/bundle), the shebang at the top of the file is:
#!/usr/bin/env ruby.exe
But when I run bin/rails, for example, I get the error:
env: ruby.exe: No such file or directory
When I remove the .exe from the end of the shebang, everything works fine. But I was just curious:
Why is this necessary
How to deal with versioning, since the other developer working on this doesn't need to remove the .exe. It's suggested to keep the bin folder in the repo, so I'd prefer to just get the .exe version working if anything.

There are no .exe files on Mac OS X or on Linux. On those platforms the Ruby executable is just called ruby.
For compatibility to those operating systems, your first line should look like this:
#!/usr/bin/env ruby

Related

What needs to be changed to run a Rails app created on Windows in Linux?

An intern made a Rails app on his Windows computer several months ago.
I transitioned his files to a RHEL server and installed Ruby, rubygems, Rails, and Ruby Version Manager.
I believe that to run his app on Windows I could just do
bin/rails server
However, when I try this on the server it says
/usr/bin/env: ruby.exe No such file or directory
So, apparently it's still expecting a Windows (.exe) version of Ruby. What do I need to do to transition this Windows app to Linux?
Check in the bin/rails file on your proyect path, probably there's a call to ruby.exe there, it's probably in the first line, change it to this
#!/usr/bin/env ruby
Probably this errors is in other files in the bin folder, check it and change it.
Also, migrating an app from windows to linux can leverage into a lot of issues, so you would need to debug it with pacience. Good luck!

Ruby 2.0.0-p353, Rails 4.0.2, Netbeans 7.4 - Cannot start webrick

I am trying to use netbeans 7.4 with Ruby 2.0.0-p353 and Rails 4.0.2. Plugin seems to work ok. I am able to generate project and everything is there, but when I try to run project I receive following message and server is not started:
C:\Ruby200-x64\bin\ruby.exe: No such file or directory -- script/rails (LoadError)
There is a comment under official plugin page that says:
I found a simple workaround, I'm using Windows 7 and created a
symbolic link between directories like this: mklink /D script bin
Now I can start and debug my Rails 4 project in Netbeans. Posted by
mgard on Aug 19, 2013
I have tried to do this but it still doesn't solve a problem. Is there anybody that can help?
The proposed solution works well from what I have seen. What is the error you are getting? Are you able to create directory link? You would need Admin rights for that and should start the command prompt "Run as Administrator". Alternatively, try right-clicking on the "bin" directory and execute "Create shortcut" that must be renamed to "script" later.
I'm using Aptana on Win 8 and came to the problem.
Now rails 4 doesn't have script/rails in the folder. We will need to create it manually in your application folder. You can simply create the folder, then mklink or copy the file in the script folder. Please take caution that your IDE will have proper access to the file you create, otherwise, you will come to the error:
c:\Ruby200\bin\rubyw.EXE: No such file or directory -- C:/Users/Zhou/Documents/GitHub/HR-SNA/script/rails (LoadError)
Go to project's root directory and execute from a console following command:
ln -s ./bin ./script
In Rails 4, script has been replaced with bin

How do I save a ruby file? (error)

I am receiving the error No such file or directory in my command line and I think it's because I am not saving the ruby files somewhere specific. All I did was create a random folder where I would save my ruby files.
Do I need to save my scripts in the original ruby folder? Thanks!
** This is Windows 7.
More info -
All I did was make a simple file named "Matz.rb" because I'm currently reading the O'reilly Ruby book. In my code all I wrote was puts "Hello Matz". I saved this on my desktop. When I go to the command line it and I write ruby matz.rb it says "ruby: No such file or directory -- matz.rb " Please help :(
If this has something to do with PATH or shells, I honestly have no idea what those really are because I just started coding last night.
You are most likely not in the right folder. You somehow need to tell the ruby interpreter where it is looking for the file.
Either make sure you're in the right folder - the cd command allows you to change location:
cd C:\Users\Username\Desktop
ruby Matz.rb
or specify the path explicitly:
ruby C:\Users\Username\Desktop\Matz.rb
By default, the ruby interpreter will look in your current directory (the location shown in your prompt) for whatever filename you give it.
Edit: I'll attempt to explain what I mean step-by-step.
When you initially open the command prompt, it will indicate what folder you are in (your "current working directory") in the prompt:
C:\Users\YourUsername >
In the above example, you are working in the C:\Users\YourUsername folder.
You can move directories using the cd command. For example, typing cd Desktop moves you into the folder called Desktop, assuming such a folder exists in your current location
You can move to another folder outside your current folder by specifying explicitly where you want to be: cd C:\Another\Place
When you run a ruby command such as ruby Matz.rb, the system knows how to find the ruby program because the installer placed its location into the PATH environment variable. Don't worry about this too much, this just explains the "magic" by which it knows what ruby means, no matter where you are.
Ruby finds the file you specify (in the above example, Matz.rb) by looking in the current directory. To re-iterate, it is looking in whatever folder is written right there in your prompt.
You can tell ruby to look outside the current folder by specifying the full path (as shown in the answer above).
To go from a new command window that you've just opened, to typing ruby Matz.rb and having it work, you need to do the following:
Move to the correct directory
Run the command
If we assume your username is alex and you have a folder on your desktop called "rubycode", which contains Matz.rb, you could do this:
Open a command prompt, which will most likely start in C:\Users\Alex
Move to the rubycode folder on your desktop: cd Desktop\rubycode. All subsequent commands will be working from within this folder.
Run the ruby command, specifying the file: ruby Matz.rb
Continue to run ruby commands as you learn ruby.
I hope that makes sense.

Error while installing jruby on windows 7

I am trying to install JRuby in my system, I follow the following steps:
Download a copy of the latest JRuby from the JRuby download page.
Unzip the file with your achive program. If you don't have one that works, download 7-Zip.
Copy the JRuby folder called jruby-1.7.2 directly to "C:/"
Set environment variables on your system. Right click "My Computer" go to "Advanced" then "Environmental Variables". Create these: JRUBY_HOME = C:/jruby-1.7.2
Next you'll have to edit the PATH variable. Add ;C:\jruby-1.1.5\bin; to the end of that variable.
And then I am running the command:
C:\Users\sitanshu\rubyApp\jruby-1.7.2>jruby -v
then it shows the following error:
jruby 1.7.2 (1.9.3p327) 2013-01-04 302c706 on Java HotSpot(TM) Client VM 1.7.0-ea-b19 [Windows Vista-x86]
NameError: uninitialized constant Java::JavaLang::ProcessBuilder::Redirect
const_missing at org/jruby/RubyModule.java:2677
ProcessManager at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:12
JRuby at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:6
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel/jruby/process_manager.rb:3
load at org/jruby/RubyKernel.java:1046
(root) at file:/C:/Users/sitanshu/rubyApp/jruby-1.7.2/lib/jruby.jar!/jruby/kernel.rb:1
So where am I going wrong and what is the solution for that?
I would test that java is updated and working
java -version
Under your environment variables, make sure you have a JAVA_HOME variable pointing to your JRE root folder, like this:
C:\Program Files\Java\jre7\
Make sure your Java JRE bin folder is also part of your PATH variable:
;C:\Program Files\Java\jre7\bin\
Additionally, when you are adding jruby to your PATH variable, make sure you are referencing the correct folder location. In the example you have given, you are installing jruby to C:\jruby-1.7.2, but then you are actually referring to this different folder C:\jruby-1.1.5 in your PATH configuration.
Also, when you are defining your JRUBY_HOME variable, make sure you are using backslash \ characters. In your example above you used a forward slash / character. Remember, that windows uses backslashes between folders.
Finally, after you've made all your environment variable changes, remember to open a new command window for your changes to take effect.

Ruby extension in C, LoadError

On my own computer I compiled a Ruby extension writen in C. Then I added require 'mytest/mytest' to my controller and it works. Then I moved the files to the server and when I start Mongrel I have the message that:
cannot open shared object file: No such file or directory - {path_to_file}/mytest.so (LoadError)
If I follow that path there is a file mytest.so.
The permissions on mytest.so are set to 0777 and full path is checked, still the same.
can not recompile becouse i don't have gcc on production serv.
Do you have any ideas?
It's probably different architecture, i.e. you had i386, and this is x86_64. Check with uname -a and file mytest.so
yeah you're probably going to need to recompile that binary extension--you can check for dependencies with the ldd command

Resources