Psych Error: `parse': (<unknown>): could not find expected - ruby-on-rails

`':' while scanning a simple key at line 16 column 1(Psych::SyntaxError)
I'm working on a Rails application tutorial and have had the above error come up several times. When I was getting this error it seemed to only be a problem if I used one particular terminal window. I have since restarted the computer and now it is a problem regardless of what I do.
I went to the project on github and copied the information in 'secrets.yml' into my file in case that was the issue but doesn't help. In fact I'm not sure if that is even the file causing the problem because when I shift the code in that file and save it I still get the same error; at those times it points to a line that is now blank in the 'secrets.yml'
Update.
now I am getting this when i run this command
rails generate simple_form:install --foundation
-bash: $: command not found.
only change I did was start the code in 'secrets.yml' lower down, and i added a secret key to my .bash_profile, as it was suggested in tutorial and I had not done it before, and thought that might be the problem.
Update 2
shut down terminal and tied again and getting the original problem "psyche Error" Yes, thank you for your feedback, I too, although not sure why, suspect it is to do with the 'secret' file or could it be changes the tutorial told me to make to my .bash_profile. The instructions were not very clear, wondering if that is where I messed up. If that is so then I would not know how to fix that.

The Psych gem is the wrapper around libyaml and used within Ruby's YAML class, so it's not surprising you think it could be the 'secrets.yml'; a YAML config file. I'd stay the course and find what isn't being formatted correctly.

Related

Rails App Suddenly Not Working

I was just working on one of my models when my Rails app would not work anymore. Even typing out commands like rails -v, rails, c, bundle install, or any command is giving out the same error. What's causing it is a syntax error on the file fileutils.rb. I'm using the ruby version ruby-1.9.3-p551.
First set of error messages.
(I have not included the middle part of the error messages.)
Last set of error messages.
I do not understand as to what caused the file fileutils.rb to be modified or be syntax errored.
I have modified the fileutils.rb by copy-pasting lines 309-421 from another fileutils.rb file.
I got it working again but I am still confused as to what corrupted my file.

Rspec having issues with file path

I am basically having the exact same issue as this user on this question:
Rspec cannot load error
Specifically, when I look at the error log, I see that for some reason it is adding an extra "/spec" to the file path in loading the static_pages_spec.rb file
/Users/anantvinjamoori/.rvm/gems/ruby-2.1.1#railstutorial_rails_4_0/gems/rspec-core-
2.13.1/lib/rspec/core/configuration.rb:819:in `load': cannot load such file --
/Users/anantvinjamoori/helpondemand/sample_app2/spec/spec/requests/static_pages_spec.rb
(LoadError)
This directory does not exist on my computer, so it is no surprise that this error is being generated. However, I am not sure how to stop it from doing this. The previous user just said he "would check his commits" and never followed up. How can I stop RSpec from doing this incorrect path assignment?
Because it seems others have had this problem, thought I would contribute my mistake (even though it may seem stupid)
I was executing rspec from the wrong directory from the terminal (ie i was executing it from the spec directory itself, which was probably the reason the extra /spec was being added.
Bottom line: restarting your terminal never hurts!

rails console yaml parse error - applying solutions

BACKGROUND Complete newbie to coding working thro’ RailsTutorial on a windows 7 PC– I’ve stalled on chap 4.2 with an YAML error running “rails console” from a command prompt with Ruby on Rails.
I need tips on how to interpret and use some specific answers (below) that I found posted on stackoverflow/google groups/github.
I’ve tried to meet forum criteria for questions. If any of my confusions are too basic here please let me know which & where else I might try.
The error -
~\Sites\sample_app rails console
C:/a_installers/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:154:in 'parse
: (<unknown>): couldn't parse YAML at line 44 column 11 (Psych::SyntaxError)
from C:/a_installers/RailsInstaller/Ruby1.9.3/lib/ruby/1.9.1/psych.rb:
54:in 'parse_stream'
(40 more lines like this)
Not sure what useful context I can supply.. possibly that I used Railsinstaller and later Pik (instead of RVM) on Windows 7, that I installed ralis/ruby programs under c:\a_installers\railsInstaller and that I’ve updated PATH to include ruby bin folders.
QUESTION The advice I'm having difficulty interpreting/using is..
rails error, couldn't parse YAML suggests
a. Run the YAML code through yamlint.com
Which YAML file? All those in the error listing? I think I’m running rails console from my installed rails program area (above), there I found 60 odd files with “ *.yml “ – do I have to run all these through YAMLlint.com?
b. Manually Fix the YAML code
One example given was " fixing invalid yaml " involving splitting yaml code for a local date into lines.This was not applicable – I couldn’t find any such code in any of the 60 odd “ *.yml “ files under railsinstaller on my system
c. “load the old YAML parser (syck) with code xxx in config/boot.rb”
Two problems…
(1) I couldn’t find boot.rb in my the rails/ruby program area
(2) I’m torn between two contrary views expressed
“Psych is the new one, the one you should be using you have some invalid yaml somewhere.”
And
“wrong… ruby should use a parser that is both maintained and supports existing usage, even if that usage is further from the spec. If only there were such a thing. Until there is, they should use syck..”
In summary, not sure which files to amend, how to do that, how to check that. if it’s advisable instead to do a workaround (reverting to syck) and if so in which directory and with which files.
another source rails-yaml-config-best-practice advised
“configure parameter inside environment.rb.” use a github code called “settings logic”
Not sure how to do this..do I need to learn YAML? Tutorial hasn’t even started Ruby yet – is this
Not sure where to do this – couldn’t find environment.rb in my rails/ruby program area – it seems to be part of my application (sample_app)
In ..Settings_logic …the notes seem to bring me full circle to 1. above.
“..Note: Certain Ruby/Bundler versions include a version of the Psych YAML parser which incorrectly handles merges (the << in the example above.) If your default settings seem to be overwriting your environment-specific settings, including the following lines in your config/boot.rb file may solve the problem:
require 'yaml'
YAML::ENGINE.yamler= 'syck'
To apply this solution I still need to resolve question 1 c (2)
3 General advice - My inability to start rails console seems an absolute barrier for me to use ROR- a couple of general questions - Do practitioners use rails console for actual development or just learning? Can I learn RoR without rails console?
Many thanks for your patience, time and attention.

Newbie help with Rails/Ruby. Totally lost! (Mongrel related, I think) 503 Errors

I am on the verge of actually hiring someone to fix this
for me, but I hope it doesn't come to that.
I have no experience with Rails/Ruby, but I do know my way around
computers in general.
I have two domains on one server (Hostingrails, I am beginning to hate
them more and more these days).
My secondary domain works 100% fine.
But for the past few days, my primary domain has not been working, it
has been giving me 503 Errors. I've opened a ticket regarding this, and
they told me to SSH into my server and reset "Mongrel". I've done this
using the code they gave me; "mongrel_rails start -d -e production
-p13930"
It seemed to have worked, but the problem was still there. The log says
the error is something about:
"require': no such file to load -- dispatcher (LoadError)"
I've re-opened a ticket concerning this, and Hostingrails basically told
me that it is not their problem anymore and that it's solely up to me to
fix it. Brilliant.
So I spent a good part of the day looking and changing things around
through SSH (probably wasn't the greatest idea) but I still keep getting
503'd on my website.
However, I recently found out that my index file HAS to be index.html,
or it will not render the page. index.htm or index.php will result in a
503. If I set the index page to index.html, it worked. Which is strange,
my htaccess file allowed for all.
Another problem, I think I have inadvertently changed something in my
settings while I was SSH'd in. When I do "bundle install" it installs
the gems into my own private webspace, for example /home/mywebsite. But
I believe on my shared plan, all the rails/ruby/gems etc are all under
/usr/local/rvm/gems/ruby-1.9.2-p0/ which I don't think I have access to.
How do I change the directory to the default one? For example, before
the error log said:
/usr/local/rvm/gems/ruby-1.9.2-p0/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
Now it says:
/home/mysite/.gems/gems/activesupport-3.0.0/lib/active_support/dependencies.rb:239:in
`require': no such file to load -- dispatcher (LoadError)
I think that's everything for now. Here are the rails installed on my
server by the host:
Installed at (3.0.0): /usr/local/rvm/gems/ruby-1.9.2-p0
(2.3.8): /usr/local/rvm/gems/ruby-1.9.2-p0
(again, I think my mongrel is looking in the wrong place, as my gems are
now being installed into /home/mywebsite/ instead of
/usr/local/rvm/gems/) Is it possible to someone reset the settings I've
changed back into my host's default one?
Would anyone be willing to take the time and try and fix this with me? I
am pretty annoyed at Hostingrails, since I didn't do anything to create
this problem, and they are outright refusing to help me. Why is my
primary domain getting 503 errors when my secondary domain works fine?
Mongrel is not compatible to ruby 1.9.2. You need use a fork of mongrel to use it https://github.com/kyusik/mongrel_cluster
I advice you to user thin/passenger or unicorn instead of mongrel.
I found a little blog post about problem with Mongrel and ruby 1.9.2 http://xaop.com/blog/2010/08/04/deploying-rails-3-on-ruby-1-9-2/
Maybe you could try using Ruby 1.8.7 - it causes less trouble in general at this time.
Not an answer to your question in particular, but if you're new to Ruby and Rails, then hosting your own stuff can be a daunting task.
Instead, try Heroku - simply push your Rails app to Heroku with git and you're good to go. They support custom domainnames for free.

Rubys on Rails project Using Aptana

I am having a major issue with creating a Rails Project on Aptana (using mac os x). Basically, when i try starting a Rails project and name a file, it comes back with an error saying:
"!!! Path to log file not valid: /Users/fab/Documents/Aptana Studio Workspace/test.rb/log/mongrel.log mongrel::start reported an error. Use mongrel_rails mongrel::start -h to get help."
and then a pop up comes up saying: "Rename the directory to no longer have a space"
After all this, i tried renaming the directory without spaces, but then when i went back to create a new project again it came back with this pop up that says "resource'/fab/public'does not exist." Under this there is a list of two options: "periodic workshop save" and "replace project index file."
What does this mean, and how can i fix the problem?
Any advise would be much appreciated!
Omarj
Mongrel used to have a bug with writing log files, and for whatever reason it's trying to create a path relative to a file (rather than a folder) in your case. i think they also had issues with spaces in the path.
Do NOT rename your workspace path, or Studio/RadRails won't see the files anymore (as you saw above) - because you moved them.
I suggest renaming the folder back. This question is pretty stale, so mongrel is no longer widely used. you could try one of the other server types, like webrick.
Hey, I don't have an answer to your question. However, would advise you that if you are starting to get your hands dirty with Ruby and Rails, then consider TextMate as your IDE instead of RadRails.

Resources