I'm trying out a Q&A application written in rails 3.1 on my Ubuntu system. After I run the server (rails server), and enter the localhost:3000 url in the browser, I'm getting the following error:
/var/lib/gems/1.8/gems/jquery-rails-1.0.14/vendor/assets/javascripts/jquery.js isn't in paths:
(...."displays a list of paths including /$home/myapp/jquery-rails/ruby/1.9.1/gems/jquery-rails-1.0.14/vendor/assets/javascripts".....).
I did bundle update and it installed the jquery.js and all other .js files in that last path. But I'm still getting the same error. Any suggestions about what I might be doing wrong here?
P.S. When I enter the URL localhost:3000, it actually tries to open the URL: http://localhost:3000/session/new. Must be some application specific logic.
Remove everything in your /tmp directory and restart the Rails app.
Fixes it for me.
Related
MY CODE BASE SETUP:
Ruby on Rails Deployed locally with Postgres
Production with Heroku (staging and production servers).
MY PROBLEM: Things are "seemingly" working on local machine (no hard errors) but NOT working in production. I believe my issue has to do with sending the proper information to the ruby, file.open() command.
I'm receiving the following error on my production(staging) server:
Errno::ENOENT in Projects#show
Showing /app/app/views/projects/show.html.erb where line #276 raised:
No such file or directory # rb_sysopen - https://[bucketname].s3.amazonaws.com/path/to/instance/of/file/file_name.stl
But if I take the resulting hyperlink and copy / paste it into my web browser, the file open / download menu is prompted. What am I doing wrong here?
BACKGROUND / HISTORY:
I haven't been able to resolve and I've scoured much of the stackoverflow questions looking for answers:
ENOENT, no such file or directory but file exists ()
File Exists But Receiving ENOENT Error (I'm not using node and my server restarts everytime I deploy)
Rails 3: Errno::ENOENT exception (if CentOS is like Heroku, then we have a similar issue which no one seems to be able to answer). Not sure about my Tmp file situation. But this question sounds similar to my issue.
Carrierwave, Rails 4; Errno::ENOENT (No such file or directory - identify) (might be relevant, but I'm not pulling an imagemagick file, I'm trying to parse a non-image file)
Remove "www", "http://" from string (I tried stripping various portions of my path in order to feed the file.open() command the right format to no avail
File.open, open and IO.foreach in Ruby, what is the difference? (this helped me understand the difference between each command type, which might be my issue).
Open an IO stream from a local file or url (sounds again like a reliable fix but I don't know how to utilize this open command as the gem specifies a file.open() command vs. these open() commands).
I defined the following method in my "project model" (project.rb) which takes the project file from a particular instance and from the "project_file path" input, the gem parses an STL file for my webapp.
This particular gem--"STL_parser"--calls a file.open(filepath,'rb') command which is where I believe my app is running into issues. Here's the method I call in my model which calls the STL_parser gem:
def analyze_STL project_file
if Rails.env.development? || Rails.env.test?
full_path = project_file.current_path
else
full_path = project_file.url.to_s
end
parser = STLParser.new
parser.process(full_path)
end
The RESULTS from each case and environment are as follows:
In Development:
project_file.current_path
...for one particular instance yields on my mac:
/Users/myname/full/path/to/file/on/laptop/unique_instance_file.stl
RESULT: app works on local machine AND if I copy/paste the above path into a web browser like Chrome, it prompts a file open / download menu.
In Production Environment:
project_file.current_path
RESULT:
Errno::ENOENT error - No such file or directory # rb_sysopen
-uploads/project/project_file/instance/instance_file.stl
and clearly lacks a subdomain, so in Production, I modified the path to call the file URL from AWS as seen above:
project_file.url.to_s
https://[bucketname].s3.amazonaws.com/path/to/instance/of/file/file_name.stl
RESULT:
Errno::ENOENT error - No such file or directory # rb_sysopen
-https://[bucketname].s3.amazonaws.com/path/to/instance/of/file/file_name.stl
...but if I copy / paste that path into my web browser, the file will prompt an open / download menu.
Thus the path seems to be pointing towards the correct to the file, but the file.open() command doesn't like that path format. Thoughts? I've been banging my head now for some time!
Possibilities:
Is it a permissions thing with AWS? If so, why would other image files produced by other ruby Gems open fine in the same AWS bucket?
When I apply the full-path as a hack...the URL format for my development environment, by simply creating a variable: hacked_path = "localhost:3000"+file_path
...this generates the Errno::ENOENT No such file or directory # rb_sysopen error. But I can copy / paste that same path in my web browser and it opens a download prompt. So it seems like my browser is piecing together some information about how to open the file, but the Gem I'm calling in my webapp isn't that flexible. A friend of mine said something about my webapp not being able to read the "binary" while my local machine can?
Is this an issue of file.open(filename, 'rb') vs. open(filename, 'rb')? I wouldn't even know how to modify the gem, but I could ask the developers for help.
Is this because the my app doesn't have enough time to download the file from AWS before it tries to process the file?
CORS permissions in AWS?
Something else more simple I haven't thought of?
Thanks in advance for your help and feedback! Yes I know I need more programming fundamentals courses. Any online ones you'd recommend? Already took the one from onemonth.
I'm relatively new to Rails as well as using PassengerPhusion. I am running an Ubuntu server on Azure, and have the demo app that Passenger provides working fine. I've even changed the text on the homepage.
My question is this:
In my directory, the file directory's name for the app is passenger-ruby-rails-demo and while I am experimenting, i am changing the name of the directory to something like passenger-ruby-rails-demo-test and it returns an error message when viewing fleetpro.cloudapp.net.
I've tried looking through files trying to figure out how this is routed but haven't had any luck. Is there a file within the Rails installation that is telling Passenger to be inside the specific passenger-ruby-rails-demo directory? Pretty newbish question, but it is really bothering me!
I'm not sure about how the naming convention works in regards to the root directory name of your app "passenger-ruby-rails-demo", but I believe the name of that directory is important to running your Rails app, and might have to do something with the name of the module in your config/application.rb file which is named after your Rails app.
There is a solution though: use gem rename.
Add gem rename to your Gemfile and run bundle install.
Then in your app's root directory, run this:
rails g rename:app_to New-Name
This will basically "clone" the app with your new name. You may have to check to make sure all your config files are present afterwards, but from my experience using it, it was a quick breeze. You will most definitely have to push the new renamed app back to git or Azure.
EDIT
As an example I renamed a Rails app to show what you could expect from the output after running the command:
The Rails app's name isn't the problem, it's the PassengerAppRoot switch you'll be using:
PassengerAppRoot /path/to/your/app
Rails doesn't actually care which folder it's put into, so renaming Rails won't fix your problem.
Renaming Rails only changes the internal class references within your application (things like Rails.application.name which have very subtle implications for your app).
In your Azure server, you'll need to locate either your .htaccess / httpd.conf / nginx.conf file, and change the PassengerAppRoot to your new path. This should resolve the issue.
I'm deploying a Rails app on Heroku which requires a gem that looks for an executable in PATH. I put my executable inside /vendor/bin and then proceeded as below:
As explained in Heroku docs here, I created a .profile.d directory in the root of my app and then in it, I created a file called path.sh. In path.sh, I set the PATH variable like this:
PATH="$PATH:/app/vendor/bin"
or this
PATH=$PATH:$HOME/vendor/bin
But neither seems to work. The app is deployed successfully but when I run it, I see an application error, and in my logs, I see that this executable could not be found in PATH, thus the application crashed. The script (.profile.d/path.sh) is run for sure though, because in my Heroku logs, I am able to see other commands and the print outs I put in the very same file.
Does anyone know what to do in order to make this work? Thanks in advance.
I'm new to RoR.
I was able to install Rails and host it in Webrick (Sample App with "Welcome" controller) in my windows.
Now i have a Unix Weblogic Server along with a dedicated domian.
After exporting the .WAR file using Warbler, i accessed the Oracle Admin Console from where i deployed the .WAR file in the dedicated domain. I did all this for the Sample app with only the Welcome controller in it.
But even after deploying the WAR file, on accessing the Domain along with the Port Number (:9002) i ended up with 404 file not found error On looking at the server logs,there wasn't any records relating to any error. The Application must have been deployed properly. I assume that i must have missed out on some basic configurations in the routes.rb or similar files before deploying. Can anyone Guess what are all the possibilities and if possible can anyone help me by pointing to any tuts that cover the Steps to be carried out for configuration before deployment. do i need to install both JRuby and Rails inside the server before depolyment?
I can't really guess with Eror 404 only.
You can try mapping your rails app rack config to a different base_uri.
All you need to do is wrap the existing 'run' command in a map block
try doing this in your rails 'config.ru' file:
map '/mydepartment' do
run Myapp::Application
end
Now when you 'rails server' the app should be at localhost:3000/mydepartment .
Not sure if this will give you the desired outcome, but worth a try.
One more thing you also add this to your config/environments/production.rb and config/environments/development.rb (if on production mode):
config.action_controller.asset_path = proc { |path| "/abc#{path}" }
otherwise when you call your helpers such as stylesheet_link_tag in your views, they will generate links without the "/abc".
Also, find some guides you may refer for good support.
JRubyOnRailsOnBEAWeblogic.
Use JRuby with JMX for Oracle WebLogic Server 11g
Let me know if it is not resolved.
I'm been working on a rails 3.1 app with one other dev.
I've just pulled some of his recent changes, using git. And am now getting a 403 on any page I try to visit.
You don't have permission to access / on this server.
I'm running the site locally through passenger.
Oddly, when I start the app using rails' internal server. I can visit the site at http://0.0.0.0:3000
Looking at the changes in this recent pull, the only files have changed are some javascripts, some html the application.rb, routes.rb and a rake file.
How do I debug this, I'm a bit lost on where to start?
EDIT:
If I roll back to an earlier version the site works, through passenger. Which leads me to believe the problem is within the rails app, rather than an Apache error. Or it could be a permissions thing, can git change file permissions in this way?
IMHO this is a configuration error in Apache or wrong directory layouts. Make sure that the passenger_base_uri still points to the public folder inside your rails project and that there are no hidden .htaccess files which block access. Also verify that your sym-links are correct (if there are any). Also check your Apache error log.
Start by launching your console to see if rails and your app can be loaded.
In your application root directory type :
rails console