Ruby no such file or directory windows

I installed Ruby 1.9.2 on my Win 7 machine. Created a simple analyzer.rb file. It has this one line: File.open("text.txt").each {|line| puts line} When I run the code, it gives me this error: an...

I installed Ruby 1.9.2 on my Win 7 machine. Created a simple analyzer.rb file. It has this one line:

File.open("text.txt").each {|line| puts line}

When I run the code, it gives me this error:

analyzer.rb:1:in `initialize': No such file or directory - text.txt (Errno::ENOENT)
from analyzer.rb:1:in `open'
from analyzer.rb:1:in `<main>'
Exit code: 1

I don’t get it. There is a text.txt file in the same directory as the analyzer.rb file. I also tried feeding the absolute path of the file, C:Ruby192text.txt, but no dice. What am I missing?

sawa's user avatar

sawa

164k42 gold badges272 silver badges374 bronze badges

asked Jul 4, 2011 at 2:49

Ege Ersoz's user avatar

1

Start by figuring out what your current working directory is for your running script.
Add this line at the beginning:

puts Dir.pwd.

This will tell you in which current working directory ruby is running your script. You will most likely see it’s not where you assume it is. Then make sure you’re specifying pathnames properly for windows. See the docs here how to properly format pathnames for windows:

http://www.ruby-doc.org/core/classes/IO.html

Then either use Dir.chdir to change the working directory to the place where text.txt is, or specify the absolute pathname to the file according to the instructions in the IO docs above. That SHOULD do it…

EDIT

Adding a 3rd solution which might be the most convenient one, if you’re putting the text files among your script files:

Dir.chdir(File.dirname(__FILE__))

This will automatically change the current working directory to the same directory as the .rb file that is running the script.

answered Jul 4, 2011 at 4:57

Casper's user avatar

CasperCasper

33.1k4 gold badges83 silver badges78 bronze badges

3

ENOENT means it’s not there.

Just update your code to:

File.open(File.dirname(__FILE__) + '/text.txt').each {|line| puts line}

answered Jul 4, 2011 at 2:56

Till's user avatar

TillTill

22.1k4 gold badges58 silver badges88 bronze badges

3

Please use chomp() or chomp() with STDIN

i.e. test1.rb

print 'Enter File name: '

fname = STDIN.gets.chomp()  # or fname = gets.chomp()


fname_read = File.open(fname)

puts fname_read.read()

shivam's user avatar

shivam

15.8k3 gold badges54 silver badges70 bronze badges

answered Apr 18, 2012 at 12:31

Bhaveshkumar's user avatar

Try using

Dir.glob(".") 

To see what’s in the directory (and therefore what directory it’s looking at).

answered Jul 4, 2011 at 4:50

Andrew Grimm's user avatar

Andrew GrimmAndrew Grimm

76.8k54 gold badges197 silver badges335 bronze badges

Next to being in the wrong directory I just tripped about another variant:

I had a File.open(my_file).each {|line| puts line} exploding but there was something by that name in the directory I was working in (ls in the command line showed the name). I checked with a File.exists?(my_file)
which strangely returned false. Explanation: my_file was a symlink which target didn’t exist anymore! Since File.exists? will follow a symlink it will say false though the link is still there.

answered Sep 15, 2011 at 16:46

wrtsprt's user avatar

wrtsprtwrtsprt

5,2834 gold badges20 silver badges28 bronze badges

Ditto Casper’s answer:

puts Dir.pwd

As soon as you know current working directory, specify the file path relatively to that directory.

For example, if your working directory is project root, you can open a file under it directly like this

json_file = File.read(myfile.json)

answered Apr 2, 2015 at 18:07

Hua2308's user avatar

Hua2308Hua2308

4516 silver badges14 bronze badges

I am also experiencing this issue.

ruby 2.3.3p222 (2016-11-21 revision 56859) [i386-mingw32]
parallel_tests 2.16.0

parallel_cucumber features/dfe
4 processes for 6 features, ~ 1 features per process
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)

parallel_cucumber features/dfe —verbose
4 processes for 6 features, ~ 1 features per process
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/brazil_keyword_search.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/mexico_deal_inquiry.feature» «features/dfe/someFeature.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/someFeature.feature» «features/dfe/someFeature.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/someFeature.feature»
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)
C:Ruby23binruby: No such file or directory — bundle (LoadError)

Tests have failed for a parallel_test group. Use the following command to run the group again:

C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/brazil_keyword_search.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/someFeature.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/someFeature.feature» «features/dfe/someFeature.feature»
C:/Ruby23/bin/ruby — bundle exec cucumber —profile parallel «features/dfe/someFeature.feature» «features/dfe/someFeature.feature»

Took 0 seconds
cucumbers Failed

bundle exec cucumber —profile parallel «features/dfe/someFeature.feature»
cannot load such file — __out
Error creating formatter: —out (LoadError)
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/constantize.rb:17:in require' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/constantize.rb:17:in rescue in constantize’
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/constantize.rb:6:in constantize' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/configuration.rb:192:in formatter_class’
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/configuration.rb:179:in block in formatter_factories' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/configuration.rb:175:in map’
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/configuration.rb:175:in formatter_factories' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:190:in formatters’
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:172:in report' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/runtime.rb:64:in run!’
C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/lib/cucumber/cli/main.rb:32:in execute!' C:/Ruby23/lib/ruby/gems/2.3.0/gems/cucumber-2.4.0/bin/cucumber:8:in <top (required)>’
C:/Ruby23/bin/cucumber:22:in load' C:/Ruby23/bin/cucumber:22:in

I’m going to keep digging, but wanted to give this thread some more momentum. Making the gem windows compatible is still a TODO in the readme so I almost moved on until I saw the various comments saying that this should work in windows.

9 Replies

  • Did you follow

    http://community.spiceworks.com/education/projects/Scripting_Spiceworks_Reports

    Best practice will be to copy the file called run_report.rb ro the bin directory (same directory as ruby)


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Ariel Martinez

    Looks like you didn’t follow the instructions that Susan160 posted.

    http://community.spiceworks.com/education/projects/Scripting_Spiceworks_Reports

    You have to copy run_report.rb to the rpt folder first, that’s why ruby doesn’t find it.

    Edit: Yasaf beat me to it, hehe.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tremayne Carr

    I have tried that as well.  I copied the file over and ran this command and a new group of errors popped up:

    C:Program FilesSpiceworksbin>ruby run_report.rb -?
    Error: you must pass an email address (-e EMAIL) or set env variable SW_EMAIL

    Did what it asked and repeated the command:

    C:Program FilesSpiceworksbin>ruby run_report.rb -e me@myhost.com
     -p mypassword -l
    Error: you must pass an email address (-e EMAIL) or set env variable SW_EMAIL


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Ariel Martinez

    Susan specified that you have to put the email you use for spiceworks.

    Are you using that one?


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tim Miller

    Try copying the run_report.rb to the «RPT» folder.

    Then run the “..binruby run_report.rb –e (Spiceworks username) –p (Password for User) –f pdf (Report Number)”

    I then copied the latest run_report.rb script from the install directory/pkg/gems/spiceworks-2.0.XXXXX directory (where XXXXX is the latest release) to this rpt directory.

    I have made a create and email reports also. It was easier for me this way.

    http://community.spiceworks.com/how_to/show/1010


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tremayne Carr

     Yes I am putting that one. 


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tremayne Carr

     nm….. I fat fingered the email addy..  Works now.  Sorry for your troubles.  


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tim Miller

    C:Program FilesSpiceworksbin>ruby run_report.rb -e me@myhost.com
     -p mypassword -l
    Error: you must pass an email address (-e EMAIL) or set env variable SW_EMAIL

    I think I have had that error before when I wasn’t using the spiceworks password that I setup.

    Also, according to you command you are not running the command in the rpt folder try putting the run_report.rb in the «C:program filesspiceworksrpt» folder. Then run the «..binrub run_report.rb» command.


    Was this post helpful?
    thumb_up
    thumb_down

  • Author Tim Miller

    TreyCarr wrote:

     nm….. I fat fingered the email addy..  Works now.  Sorry for your troubles.  

    Okay good to hear.

    It is always the simple things that bite us.


    Was this post helpful?
    thumb_up
    thumb_down

Part of the joy of having a ‘bare bones’ DIY host is that sometimes you have to figure shit out on your own. I am not a great web developer, nor a Ruby expert. But, I learn more each time something breaks — you know, Type II fun. Most recently, I came to understand and fix a new error on my web server: env: ruby26: No such file or directory.

I previously wrote about my website setup here. The short version is: I use Jekyll, I host on NearlyFreeSpeech, and I deploy with git using a post-receive hook. The source is mirrored on GitHub. Overall, it is very smooth and works great — except when it breaks.

It took two instances of this recent error for me to fully understand what was happening. I’ll explain the error first, then discuss the solution.

The error: No such file or directory

A few months back, deploying with git suddenly stopped working. On GitHub you can view the full source of my post-receive git hook. Bundler was failing in the final step of the script:

bundle install --jobs 4 --retry 3

bundle exec jekyll build --destination $PUBLIC_WWW

with the following error:

env: ruby25: No such file or directory
*** Error code 127

Stop.

Prior to this, the last time I had published a post, everything was working. Now, suddenly, “ruby25” could not be found? More curious, if I simply ran jekyll build, it succeeded. Only when using Bundler, bundle exec jekyll build, was it producing the error.

I posted on the member forums, but didn’t fully grasp the answer provided. With some uncertainty, I decided to just redo/reconfigure my RubyGems setup (again, described here). After that, everything started working again, so I didn’t give it much thought other than “lol computers”. But then the error happened again a few days ago, though this time slightly differently:

env: ruby26: No such file or directory

First ruby25, now ruby26. This second time around, I suddenly realized what had happened. Ruby was upgraded to a new version while the old Ruby version was removed, and Bundler was referencing the old version.

Debugging

NearlyFreeSpeech has this concept of realms, which refers to “the combined collection of all the operating system files, programming languages, and third party applications present in its environment. These are the tools available to your site for web applications, and for use over ssh.” Periodically, realms get updated and upgraded automatically (depending on your settings). When this happens NearlyFreeSpeech will notify you, but it usually has no impact on my site.

I realized that these “No such file or directory” errors were happening after realm upgrades. I ssh’d into my server, and ran gem env:

RubyGems Environment:
  - RUBYGEMS VERSION: 3.0.6
  - RUBY VERSION: 2.7.1 (2020-03-31 patchlevel 83) [amd64-freebsd11]
  - INSTALLATION DIRECTORY: /home/private/.gem
  - USER INSTALLATION DIRECTORY: /home/private/.gem/ruby/2.7
  - RUBY EXECUTABLE: /usr/local/bin/ruby27
  - GIT EXECUTABLE: /usr/local/bin/git
  - EXECUTABLE DIRECTORY: /home/private/.gem/bin
  - SPEC CACHE DIRECTORY: /home/private/.gem/specs
  - SYSTEM CONFIGURATION DIRECTORY: /usr/local/etc
...

The relevant information here is the path to the Ruby executable: RUBY EXECUTABLE: /usr/local/bin/ruby27. The output of bundle env was similar:

Bundler       2.1.4
  Platforms   ruby, amd64-freebsd-11
Ruby          2.7.1p83 (2020-03-31 revision a0c7c23c9cec0d0ffcba012279cd652d28ad5bf3) [amd64-freebsd11]
  Full Path   /usr/local/bin/ruby27
  Config Dir  /usr/local/etc
...

Ah ha! — ruby27. Now the original error made sense. Of course, ruby26 could not be found. Ruby had been upgraded from 2.6 to 2.7, thus the old executable ruby26 had been replaced with the new one, ruby27.

The obvious question here is why doesn’t NearlyFreeSpeech keep multiple Ruby versions installed? I don’t know. You get what you pay for, I guess? (And I pay about $1.66 USD per month. *shrugs*)

The solution

To fix the problem, I ssh’d into my server and reinstalled Bundler: gem install bundler. Then, I re-ran bundle install for the first time. These two steps reinstalled everything for the new Ruby version, and now everything was working again. (This also explains why my previous decision to redo my entire RubyGems setup worked.)

I’m not entirely sure how/why Bundler was referencing the old Ruby executable. I’m assuming it caches this based on your first bundle install? Again, I am not a Ruby/Bundler expert, and I could not find anything about this in the docs. Can you specify a Ruby version for Bundler to use?

To prevent this error from happening in the future, I now run gem install bundler as part of my post-receive git hook. The next time that Ruby is updated, my deployment process should continue to “just work”.

gem install bundler --no-document
bundle install --jobs 4 --retry 3

bundle exec jekyll build --destination $PUBLIC_WWW

It does feel somewhat awkward to install Bundler every time I deploy, but: (1) it works, (2) I’m not publishing new posts more than a couple times a week, if that, and (3) it is quite fast with --no-document. I think I might be able to improve this workflow using bundle config, but I’m not sure.

In any case, if you also host on NearlyFreeSpeech (which I strangely do recommend) and ran into this issue, I hope this helps. And if there is something I can improve here, let me know!

Update

15 December 2020

There’s another possible solution here. You can specify the Ruby version in your Gemfile.

source 'https://rubygems.org'

ruby '2.7'

gem 'jekyll', '~> 4.0'

This will produce a hard failure when the Ruby version changes on NearlyFreeSpeech. Then you can update your Gemfile and local Ruby version, and redeploy your site.

0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

1

12.09.2013, 21:18. Показов 5857. Ответов 13


Привет Всем, друзья, прошу у Вас помощи: недавно прослышал про язык RUBY, говорят лёгкий в понимании, хорошо программы пишутся, скачал его установил, нашёл самоучитель, делал всё по инструкции: написал в Microsoft Office: puts 1+2 и назвал calc.rb, пытаюсь запустить через cmd но выдаёт такую ошибку:
«ruby: no such file or directory — calc.rb (LoadError)»

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Модератор

Эксперт функциональных языков программированияЭксперт Python

33837 / 18869 / 3975

Регистрация: 12.02.2012

Сообщений: 31,650

Записей в блоге: 12

13.09.2013, 08:11

2

Цитата
Сообщение от Кондор
Посмотреть сообщение

написал в Microsoft Office: puts 1+2

— в Worde написал? И где сохранил? Программы нужно писать в notepad (notepad++) или тому подобном текстовом редакторе.



1



0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

13.09.2013, 14:24

 [ТС]

3

Пробовал и на D:/ сохранять и на C:/ и C:/users/Kondor попробую скачать NotePad++

Добавлено через 13 минут
О! Теперь уже выглядит не как текстовый файл, а как иконка RUBY, но ошибка та же((



0



Модератор

Эксперт функциональных языков программированияЭксперт Python

33837 / 18869 / 3975

Регистрация: 12.02.2012

Сообщений: 31,650

Записей в блоге: 12

13.09.2013, 14:27

4

Выложи этот файл на форум.

Добавлено через 38 секунд

Цитата
Сообщение от Кондор
Посмотреть сообщение

выглядит не как текстовый файл, а как иконка RUBY

— программист смотрит не на иконку, а внутрь файла.



1



227 / 225 / 23

Регистрация: 30.01.2013

Сообщений: 720

13.09.2013, 16:43

5

Смеялси в слух!!!

Всех тоже с днем программиста!



2



0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

13.09.2013, 17:58

 [ТС]

6

Вот в ZIPке тот файл:



0



Модератор

Эксперт функциональных языков программированияЭксперт Python

33837 / 18869 / 3975

Регистрация: 12.02.2012

Сообщений: 31,650

Записей в блоге: 12

13.09.2013, 18:32

7

Файл правильный. Тогда опиши, как ты его запускаешь из Ruby.



1



0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

13.09.2013, 21:35

 [ТС]

8

Запускаю CMD и там пишу RUBY CALC.RB



0



Эксперт С++

5826 / 3477 / 358

Регистрация: 08.02.2010

Сообщений: 7,448

14.09.2013, 08:18

9

Кондор, а текущую рабочую директорию сменил? Сам файл calc.rb находится в рабочей директории?

Цитата
Сообщение от Кондор
Посмотреть сообщение

написал в Microsoft Office

В Excel, надеюсь?



0



0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

14.09.2013, 11:41

 [ТС]

10

Цитата
Сообщение от Nameless One
Посмотреть сообщение

Кондор, а текущую рабочую директорию сменил? Сам файл calc.rb находится в рабочей директории?

В Excel, надеюсь?

Сейчас писал в NotePad++ а насчёт рабочей директории не знал, подскажите как её сделать и сменить, первый раз с Ruby сталкиваюсь))



0



Эксперт С++

5826 / 3477 / 358

Регистрация: 08.02.2010

Сообщений: 7,448

15.09.2013, 04:39

11

Цитата
Сообщение от Кондор
Посмотреть сообщение

первый раз с Ruby сталкиваюсь))

Руби тут не причём. Это базовые основы работы в командной строке Windows.

После того, как запустится командная строка, выполни команду pwd. В результате ты увидишь текущую рабочую директорию. Она должна совпадать с директорией, в которой сохранён файл calc.rb. Если calc.rb находится в другой директории, тебе нужно сменить рабочую директорию на ту, в которой он сохранён, с помощью командны cd НОВАЯ_ДИРЕКТОРИЯ, где НОВАЯ_ДИРЕКТОРИЯ — это директория, которую ты хочешь сделать рабочей.



0



Модератор

Эксперт функциональных языков программированияЭксперт Python

33837 / 18869 / 3975

Регистрация: 12.02.2012

Сообщений: 31,650

Записей в блоге: 12

15.09.2013, 10:31

12

Цитата
Сообщение от Nameless One
Посмотреть сообщение

После того, как запустится командная строка, выполни команду pwd

— в XP исконно UNIX-овая pwd отсутствует. Но она и не нужна, т.к. по умолчанию имя текущей директории отображается в приглашении.



2



Эксперт С++

5826 / 3477 / 358

Регистрация: 08.02.2010

Сообщений: 7,448

15.09.2013, 10:37

13

Catstail, точно, забыл.

Вообще, аналогом pwd будет в данном случае cd без аргументов или echo %cd.



2



0 / 0 / 0

Регистрация: 12.09.2013

Сообщений: 7

15.09.2013, 12:08

 [ТС]

14

Спасибо большое! Помогло, работает!

Добавлено через 1 минуту
Catstail и Nameless One «Спасибо» ставлю!



0



Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Purvi Agrawal

Hi,

I have rails 5 and using the command «ruby binrails server» to run rails server as mentioned in the video.
But I get the following error :

C:RailsInstallerRuby2.2.0binruby.exe: No such file or directory — binrails (LoadError)

Any inputs on what’s wrong. I have Windows and have used Railsinstaller to install ruby and rails

14 Answers

Ethan Rivas

Ok, let’s see:

  • First of all the command that you’re running (if it’s ruby bin/rails server) is wrong, the correct command you should be running is bin/rails server (I saw that you’re working on windows so you can Ignore this).

  • Secondly this command have to be run inside the rails project directory (but you already told me that you are inside).


Maybe the problem is the command that are you trying to run is not the correct, but, the error says that you’re not inside a rails project folder, so that’s weird.

  • Try creating a new rails project typing:

rails new new_project

  • Go to your project folder:

cd new_project

  • After that try again:

bin/rails server (in your case ruby bin/rails server)

Jay McGavren

STAFF

Purvi Agrawal , I suspect the difference is that you originally installed using Rails Installer, and you’re still launching a command prompt/terminal that came with Rails Installer. It seems likely that commands will work differently there.

First:

  • Change into your Rails app directory.

Then, I would try the following things, in order. Some of them will probably fail. Continue using the first one that works:

  • Run bundle exec rails server
  • Run rails server
  • Run ruby bin/rails server (Note that’s a forward slash, not a backslash.)
  • Run bin/rails server

I would appreciate it if you would reply here and let me know which one, if any, works for you. Even better would be if you copy and paste the commands and their output, including the ones that failed and the one that eventually works.

Purvi Agrawal

Ethan Rivas Yes. I changed the directory to my rails app and then run the command.
Should I do it outside the rails project folder ?

Ethan Rivas

Purvi Agrawal Yes, you have to be inside your project folder before you run the command, do you have the same error if you run this command: rails s ?

Ethan Rivas

Purvi Agrawal Can you run this command bundle install --binstubs and after that try again?

Purvi Agrawal

@Ethan Rivas Is rake supported in rails 5 and higher ?
I think its deprecated !

Purvi Agrawal

@Ethan Rivas Can you please tell me y did u ask me to install binstubs ?

Purvi Agrawal

@Ethan Rivas Ok. But I am just trying to understand the significance of that command. Any idea what it helps with ?

Purvi Agrawal

@Ethan Rivas Cool. Thanks !

Purvi Agrawal

@Ethan Rivas Nope. I tried the commands. Getting the same error.

Jay McGavren

STAFF

Purvi Agrawal , out of curiosity, what version of Windows are you running?

By the way, at the time of this reply, Rails Installer came with Rails 4.2, not Rails 5. So while it should work on Build a TODO List Application With Rails 4, things won’t match up exactly with Rails 5 Basics. Just something to be aware of.

Purvi Agrawal

Hi Jay,

I am using the git bash command prompt. I installed it separately.
I am in my rails app directory and interestingly all the above mentioned command works !

Purvi Agrawal

Jay McGavren Thanks a lot Jay for taking out time and making me aware of the silly mistake I was doing !
A lesson learnt well for the future :)

Eylon Cohen

Hello,
I get something different —
«Could not find gem ‘sqlite3 X86-mingw32’ in any of the gem sources listed in your Gemfile
Run ‘bundle install’ to install missing gems.»

I looked for this specific gem and installed it, and got a message telling me about the missing gem ‘puma (~> 3.) x86 mingw 32.

bundle install does not deliver an error message but does not help as well. bundle exec rails server gives the same «Could not find gem» error message.

what am i missing?

I am working on windows and swiching ‘bin/’ with ‘ruby bin’

thank you :)


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I’ve installed Ruby 1.9.2 (standard installation) and Rails 3.0 on Windows XP. The ruby installation path is C:Ruby192. I am trying to follow the first few steps of generating a web application in the directory C:rubydev:

1. rails new hello

2. cd hello

3. ruby script/generate controller App

The first two commands work fine. But, whenever I execute the 3rd command, I get the following error:

ruby: No such file or directory — script/generate (LoadError)

I’ve checked the environment variable «PATH» it includes «C:Ruby192bin» which, I’ve verified, is the directory containing «ruby.exe». Even if I write the third command as «C:Ruby192binruby.exe script/generate controller App» still I get the same error.

Executing the command «ruby -v» gives the following output on my machine:

ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

Please tell me if there are any environment variables to be created or modified or if the installation is to be done in any special manner to make this stuff work.

Thanks in advance,

Tyro

Author

Posts: 12617

IntelliJ IDE
Ruby


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

How about trying to use the actual Windows path separator character, which is «», not «/»?

Oh, and welcome to JavaRanch! Please see the JavaRanch naming policy and change your display name to conform with this policy. Thanks!

Alwin Smith

Greenhorn

Posts: 4


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

David Newton wrote:How about trying to use the actual Windows path separator character, which is «», not «/»?

I ‘ve tried doing that. The command «ruby scriptgenerate controller App» gives the same error message.

I tried to install ruby even on Ubuntu 10.04. And that gives the same error message. I’m attaching the snaphot of the terminal window with relevant commands along with this post.

Well, thanks for pointing out, I’ve updated my screen name as per the Ranch’s policy.

ruby-trial-term.jpg

[Thumbnail for ruby-trial-term.jpg]

David Newton

Author

Posts: 12617

IntelliJ IDE
Ruby


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Ugh, please post text for text stuff, not screenshots :(

I’ve never seen this on Unix-like systems. Just as a sanity check, did you look in the script folder to make sure they’re actually there?

Hmm… I do vaguely remember running into something like this once. I’d probably just ask on the rails user list.

Alwin Smith

Greenhorn

Posts: 4


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

David Newton wrote:did you look in the script folder to make sure they’re actually there?

I looked into the script folder of the newly created dummy app (/home/alwin/rubydev/hello/script). It had just one file named «rails». The content of the file is as under:

_________________________________________________________________________________________________________

#!/usr/bin/env ruby

# This command will automatically be run when you run «rails» with Rails 3 gems installed from the root of your application.

APP_PATH = File.expand_path(‘../../config/application’, __FILE__)

require File.expand_path(‘../../config/boot’, __FILE__)

require ‘rails/commands’

_________________________________________________________________________________________________________

Is there something wrong in the way I’m trying to use ruby. I tried a simple «Hello World» ruby program and it is running.

My program (hello.rb):

_________________

print «Hello Worldn»

_________________

After saving it at desktop, I gave the following command, and it worked:

~/Desktop$ ruby hello.rb

(output: Hello World)

please advise how can I create a dummy web application using ruby and rails. I am trying to follow the book «Beginning Ruby on Rails» by «Steven Holzner» (Wrox series from Wiley). But I’m getting the same error message on all the platforms that I’ve tried.

Thanks

Alwin

Sheriff

Posts: 1367


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I think that in Rails 3 the scripts are run using the rails command rather than

ruby script/<scriptname>.

Try this and report back if you’re still getting an error message:

rails generate controller App

David Newton

Author

Posts: 12617

IntelliJ IDE
Ruby


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Oh, sorry, completely missed that you’re using Rails 3—that’s correct.

Make sure you’re using Rails 3 docs to work with Rails 3, otherwise you’re headed down a pretty long road!

Alwin Smith

Greenhorn

Posts: 4


posted 12 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Thanks Katrina and David,

I’ve found a more up to date resource for learning the framework. Now I’m referring to railstutorial.org.


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Seeing all the hype about RoR, i was interested in learning it.

So, the story so far:

downloaded binary installer, followed steps to install it.

Error: script/controller no such directory exists.

Downloaded Aptana RadRails.

Error: rails needs RubyGem 1.3.2 you have RubyGem 1.3.1 (No Idea why they couldnt include 1.3.2 if it was needed.)

Downloaded RubyMine.

Error:

C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `require’: 126: The specified module could not be found. — C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/1.9/mysql2.so (LoadError)

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2/mysql2.rb:2:in `<top (required)>’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2.rb:7:in `require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/mysql2-0.2.6-x86-mingw32/lib/mysql2.rb:7:in `<top (required)>’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `block (2 levels) in require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `block in require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/bundler-1.0.10/lib/bundler.rb:120:in `require’

from C:/Users/santu/RubymineProjects/Hello/config/application.rb:7:in `<top (required)>’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `require’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:28:in `block in <top (required)>’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `tap’

from C:/Ruby192/lib/ruby/gems/1.9.1/gems/railties-3.0.3/lib/rails/commands.rb:27:in `<top (required)>’

Searched guzillion forums.No answers.

More than anything else, i think the RoR Distribution is poorly maintained. If sql3.dll is required, why isn’t it bundled with the installer?

Just disappointed.

Easy to learn language is difficult to get started.

Katrina Owen

Sheriff

Posts: 1367


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Hi there, sorry to hear that you’ve been having trouble getting started!

Easy to learn language is difficult to get started.

To clarify, Ruby on Rails is not a language — the language is ruby and rails is a framework.

The two packages you attempted to use are both maintained separately from rails itself.

You really don’t need an IDE to write ruby/rails — have you tried just using a text editor in order to get started? It might be less frustrating.

When you say that you downloaded the binary installer, what installer was it?

Here’s how I got started with ruby and rails:

Installed the ruby language.

Installed rubygems.

Used rubygems to install rails (gem install rails)

I’ve never worked on a windows machine, so I am not familiar with the issues that crop up there, unfortunately.

santoshkumar savadatti

Ranch Hand

Posts: 95


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

I’ve never worked on a windows machine, so I am not familiar with the issues that crop up there, unfortunately.

No wonder you are a happy Person.

Well, in the 36th hour of installing it.(haven’t slept)

This time, i’m installing it the cygwin way.

Let’s hope i’ll be able to start working in a few mins.

I’m on windows 7 professional system.

Tried to install from Ruby Installer 1.9.2

Katrina Owen

Sheriff

Posts: 1367


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Good luck with cygwin — that’s the way I would go if I had to get this working on windows!

santoshkumar savadatti

Ranch Hand

Posts: 95


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Finally!!

well, not what anybody would expect me to come up eith after struggling so much.

But, i found an awesome Rails Installer for Windows.

Got me working in 2 mins.Only if i knew it ><

But on the other hand, this experience has motivated me to install centOS on my system.It is a good idea in the long term.

santoshkumar savadatti

Ranch Hand

Posts: 95


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Also, if anybody faced same problem, please note:

syntax for generateing controller is not ruby script/generate controller

I created Hello application.So, the syntax for me was:

C:RubyDevHello>Rails g controller hello

Now, maybe we know why I could not get started with Rubyinstaller

Katrina Owen

Sheriff

Posts: 1367


posted 11 years ago


  • Likes 1
  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

Glad to hear you got it working!

A note on the syntax difference you found: it looks like you just ran into the difference between rails 2 and rails 3 — rails has undergone a huge overhaul lately.

It’s worth knowing which you are working with, so you can compare that to whatever they say they are using in the tutorials and articles you use/read.

santoshkumar savadatti

Ranch Hand

Posts: 95


posted 11 years ago

  • Mark post as helpful


  • send pies

    Number of slices to send:

    Optional ‘thank-you’ note:



  • Quote
  • Report post to moderator

A note on the syntax difference you found: it looks like you just ran into the difference between rails 2 and rails 3 — rails has undergone a huge overhaul lately.

That line sums up everything.

In a way its better….we check each method carefully thereby understanding more than we would.

If you’ve ever taken a look at Ruby’s exception hierarchy, you may have noticed something weird. In addition to all of the normal exceptions like RuntimeError and NoMethodError, there’s an odd reference to Errno::*.

Exception
  StandardError
    ...
    SystemCallError
      Errno::*
    ...

If you’ve ever had the bad luck to write to disk when the disk is full, or to try to make an API call over a failing network then you’ve probably seen this type of error in action. You can trigger one right now by attempting to open a file that doesn’t exist.

irb> File.open("badfilename.txt")
Errno::ENOENT: No such file or directory @ rb_sysopen - badfilename.txt
    from (irb):9:in `initialize'
    from (irb):9:in `open'
    from (irb):9
    from /Users/snhorne/.rbenv/versions/2.1.0/bin/irb:11:in `<main>'

But what exactly are the Errono exceptions? And why are they treated differently thank other kinds of exceptions?

The Errno exceptions are essentially an adapter. They connect operating system errors to Ruby’s exception system. The operating system handles errors in a different way than Ruby does, so you have to have some kind of adapter.

In ruby, errors tend to be reported as exceptions. But operating system errors are usually just integers. So ruby defines one exception class for each possible OS error. It then sticks all of these exceptions into a module called Errno.

We can use IRB to see all of the exceptions in this module. And boy, are there a lot!

irb> Errno.constants
=> [:NOERROR, :EPERM, :ENOENT, :ESRCH, :EINTR, :EIO, :ENXIO, :E2BIG, :ENOEXEC, :EBADF, :ECHILD, :EAGAIN, :ENOMEM, :EACCES, :EFAULT, :ENOTBLK, :EBUSY, :EEXIST, :EXDEV, :ENODEV, :ENOTDIR, :EISDIR, :EINVAL, :ENFILE, :EMFILE, :ENOTTY, :ETXTBSY, :EFBIG, :ENOSPC, :ESPIPE, :EROFS, :EMLINK, :EPIPE, :EDOM, :ERANGE, :EDEADLK, :ENAMETOOLONG, :ENOLCK, :ENOSYS, :ENOTEMPTY, :ELOOP, :EWOULDBLOCK, :ENOMSG, :EIDRM, :ECHRNG, :EL2NSYNC, :EL3HLT, :EL3RST, :ELNRNG, :EUNATCH, :ENOCSI, :EL2HLT, :EBADE, :EBADR, :EXFULL, :ENOANO, :EBADRQC, :EBADSLT, :EDEADLOCK, :EBFONT, :ENOSTR, :ENODATA, :ETIME, :ENOSR, :ENONET, :ENOPKG, :EREMOTE, :ENOLINK, :EADV, :ESRMNT, :ECOMM, :EPROTO, :EMULTIHOP, :EDOTDOT, :EBADMSG, :EOVERFLOW, :ENOTUNIQ, :EBADFD, :EREMCHG, :ELIBACC, :ELIBBAD, :ELIBSCN, :ELIBMAX, :ELIBEXEC, :EILSEQ, :ERESTART, :ESTRPIPE, :EUSERS, :ENOTSOCK, :EDESTADDRREQ, :EMSGSIZE, :EPROTOTYPE, :ENOPROTOOPT, :EPROTONOSUPPORT, :ESOCKTNOSUPPORT, :EOPNOTSUPP, :EPFNOSUPPORT, :EAFNOSUPPORT, :EADDRINUSE, :EADDRNOTAVAIL, :ENETDOWN, :ENETUNREACH, :ENETRESET, :ECONNABORTED, :ECONNRESET, :ENOBUFS, :EISCONN, :ENOTCONN, :ESHUTDOWN, :ETOOMANYREFS, :ETIMEDOUT, :ECONNREFUSED, :EHOSTDOWN, :EHOSTUNREACH, :EALREADY, :EINPROGRESS, :ESTALE, :EUCLEAN, :ENOTNAM, :ENAVAIL, :EISNAM, :EREMOTEIO, :EDQUOT, :ECANCELED, :EKEYEXPIRED, :EKEYREJECTED, :EKEYREVOKED, :EMEDIUMTYPE, :ENOKEY, :ENOMEDIUM, :ENOTRECOVERABLE, :EOWNERDEAD, :ERFKILL, :EAUTH, :EBADRPC, :EDOOFUS, :EFTYPE, :ENEEDAUTH, :ENOATTR, :ENOTSUP, :EPROCLIM, :EPROCUNAVAIL, :EPROGMISMATCH, :EPROGUNAVAIL, :ERPCMISMATCH, :EIPSEC]

But why are they named so cryptically? I mean, how am I supposed to ever guess that ENOINT means «File not found?»

…There’s actually a very simple answer.

Whoever first built the Errno module  just copied the error names directly from libc. So ENOINT, in C, is the name of a macro which contains the integer error code that the OS returns when it can’t find a file.

So, to really find out what each of these does the trick is to look at the documentation for the C standard library. You can find a big list of them here. I’ve excerpted a few of the more relevant ones below:

Понравилась статья? Поделить с друзьями:
  • Ru windows server 2016 x64 dvd 9327766 iso
  • Ru windows server 2016 essentials x64 dvd 9327822
  • Ru windows automated installation kit for windows 7 что это
  • Ru windows 8 x64 dvd 915419 iso
  • Ru windows 8 pro vl x64 dvd 917810 iso