I am using paperclip + imagemagick but my images are not being correctly uploaded, and when I inspect the element it says: img alt="Missing" src="/images/medium/missing.png"
I have no idea why is it looking for the images on that path.
I am using Ruby 2.0, Rails 4.0 and Windows 7, and given the research I have already done online I understand it can be tricky to get ImageMagick and paperclip properly working on this operating system.
This is what I have already done, nothing seems to be working yet:
Installed paperclip version 3.5.2.
Uninstalled and installed ImageMagick several times (tried static and dynamic versions... x86 and x64 and nothing)
Re-checked all the commands syntax
Added the ImageMagick path on development and production config.
Paperclip.options[:command_path] = 'C:\ImageMagick-6.8.7-Q16'
Created a new rb file on config, initializers, called paperclip with the following:
require "paperclip"
Paperclip.options[:command_path] = 'C:\ImageMagick-6.8.7-Q16'
Paperclip.options[:swallow_stderr] = false
Restarted the pc, restarted the command prompt, restarted rails servers.
Nothing seems to have changed anything, my images still appear as broken links and the error I am getting is the same.
Could you please help me figure it out?
Thanks
A.-
Related
I am very new at this so apologies for the noobiness of the question.
I've forked & cloned a fully-functioning Ruby on Rails app that I will be editing/playing around with locally. I would like to be able to view it in my local browser.
Is there a standard checklist of commands to run or things to check for before being able to run it locally?
I assume I would have to look at the Gemfile and make sure everything is installed with the right versions. I already have npm installed. I installed rails, but it appears to be a different version than the Gemfile specified.
Other info:
Operating system is Mac OS High Sierra; Browser: Chrome; Text Editor: Atom or VS Code are preferred.
Thank you in advance!
It sounds like you are running the wrong version of ruby on your machine, check out RVM to manage different versions.
This error only happens when executed by the Ruby on Rails server.
I've tried bypassing Carrierwave's resize option by implementing my own but it has the same result.
when I run a script from command line (in which I require the 'mini_magick' gem). It all works flawlessly.
the MiniMagick gem seems to be installed correctly and to be honest I'm kinda out of ideas to tackle this problem.
some versions (not sure if usefull or not):
ruby - 1.9.3p545
rails - 4.1.1
mini_magick - 4.0.1
ImageMagick - 6.9.0-0 Q16
Any help is appreciated.
-edit, I'm using windows 8.1
example code:
require 'mini_magick'
filename = 'test.jpg'
image = MiniMagick::Image.open(filename)
image.resize "1000x1000"
image.format "png"
image.write "test.png"
The code above works flawlessly when executed from cmd.
thumb = MiniMagick::Image.open(i.image.path)
thumb.resize "200*200"
code snippet above throws error in RoR when placed in a controller (Create)
alternatively, uncommenting the resize option directly from carrierwave throws the exact same error.
# version :thumb do
# process :resize_to_fill => [200, 200]
# end
Also a little note:
I've disabled minimagicks validations to figure out what causes the error it threw at that time:
Failed to manipulate with MiniMagick, maybe it is not an image? original error: executable not found: "identify"
I hope this clears a few things up.
-edit
I've decided to leave windows as a dev platform and switch to linux as a dev platform. fixed all of my issues (In hindsight my error was probably due to some lacking dependencies on the imagemagick side).
I experienced a similar problem recently with the following environment:
Windows 8.1
Ruby 2.1.5p273
Ruby Dev Kit 2.1.5
Rails 4.2.0.beta4
carrierwave 0.10.0
mini_magick 4.0.1
ImageMagick6.9.0-Q16 installed at C:\ImageMagick-6.9.0-Q16
In the rails console within RubyMine, I would get:
executable not found: "identify"
after keying in just two things:
filename = 'test.jpg'
image = MiniMagick::Image.open(filename)
One of the steps was to add C:\ImageMagick-6.9.0-Q16 to my Windows PATH environment variable. At first, that didn't help. However, after closing and re-opening RubyMine, the problem went away -- I assume because the change to the PATH env var (done with an independent Windows command prompt) didn't affect the RubyMine IDE environment.
executable not found: "identify"
This is an error message from MiniMagick (Source code). I guess, as the error message says, your server cannot find executable "identify".
Make sure that your ENV['PATH'] has the path to where the "identify" exists.
I'm running into the same problem.
it works flawlessly on my localhost, but on the server (windows 2012), it only works as a rake task. when run inside the application, then it fails saying
NoMethodError (undefined method `resize' for #<MiniMagick::Image:0x28c3260>):
Unfortunately, the path variable is set...
I got it to work by doing the minimagick-stuff inside the model instead of the controller.... nasty workaround.
I'm running
RAILS_ENV=staging bundle exec rake assets:precompile
on two different machines and get different fingerprints for the same asset files. I have Rails 4.0.2 installed on both machines. The machines are
Mac OS 10.9.2 and
Ubuntu Linux 12.04
Shouldn't the fingerprints be the same no matter on which machine the assets are compiled?
EDIT: The Linux machine is an EC2 instance. So I made an AMI of it and launched a second instance. Compiling the asset on this identical instance results in the same fingerprints as created on the original instance. It seems to be a 'problem' with my development machine.
I found some additional info on a related post here that's probably more relevant regarding how checksums are calculated: How does finger print digest gets calculated in Rails 4.2
I'm also leaving my original answer below because I think it's still relevant:
I think this is behavior is working as designed. Sprockets may have changed since the time this question was asked, but I think this code comment might explain why:
# Caveat: Digests are cached by the path's current mtime. Its possible
# for a files contents to have changed and its mtime to have been
# negligently reset thus appearing as if the file hasn't changed on
# disk. Also, the mtime is only read to the nearest second. It's
# also possible the file was updated more than once in a given second.
On my macos System:
pry > File.mtime("Rakefile").to_i
=> 1605021933
On a remote Linux server, with the exact same file pushed up:
pry > File.mtime("Rakefile").to_i
=> 1606847789
In my case, I've noticed the mtime of my files get modified/updated locally (macos) for reasons that aren't clear to me. I think it's caused either by a vim plugin I'm using (fzf? an indexing tool? I haven't researched it)
If you do an MD5 on these two files they're identical though.
tldr; The assets may be identical, but the hash appears to include other information which could vary from system to system
One possible reason is that the contents may not really be the same for the same file on Mac OS X and Linux. The line feeds and carriage return characters are not handled the same way in Linux and Max OS X.
Try the same experiment with precompile the assets on different Macs to confirm if the Macs generate the same fingerprint.
I have a rails app in production and after I pushed changes to it that included ImageMagick and Paperclip, it started giving me a 500 error. It runs beautifully on my local machine, and all my logs say are --
"Connecting to database specified by database.yml"
over and over and over again, so I'm not producing an error that gives me any kind of direction with where to start.
My production box is running Ubuntu 10.04. Let me know if you need any more information as I'm sure there could be something else happening. Like I said, the app runs fine on my local machine and everything works. Everything was running fine on the production machine before I added the image uploading.
================= UPDATE =================
Just to fill in extra info, I have checked the installation of both the rmagick gem in the application on the production box and the installation of ImageMagick via "identify -version" on the production box and both are installed.
================= ANOTHER UPDATE =================
I started up the application in the production environment on my local machine and everything ran just fine... still won't pull up on my production server though
================= YET ANOTHER UPDATE =================
I found an identical problem and the question was "answered" but didn't actually provide any information as to how to solve it. Thoughts?
Paperclip in Production with Unicorn: uninitialized constant Paperclip (NameError)
So the problem was that unicorn wasn't recognizing my newly installed gems, all I had to do was simply manually stop and then manually start unicorn and everything got taken care of.
In the application's root directory through SSH--
service unicorn_"app name" stop
followed by
service unicorn_"app name" start
I have created a rails 4.0.0.rc1 project on my desktop pc using Ruby 1.9.3. When I try to run it on my laptop I always get the above exception, no matter which page I request. It even happens on /rails/info/properties. Both computers use the same Ruby and Rails version.
The project still works fine on my desktop PC. I am using a Rubymine development server, I have tried running Rails S in command prompt, but I still get the same error.
I realise this means that I am somehow passing a parameter when I should not be, but I have no idea how I'm doing that. What is going on here?
I have tracked down the gem that seems to be causing this. In this case it seems to be 'Therubyracer' causing this issue for me. For some reason I do not have to include it in my gemfile on my desktop, but my laptop does require it to be included.