I'm trying to setup the tesseract-ocr gem in my rails environment. I have ran brew install tesseract and then ran a bundle install on the app and that all runs without errors however when starting the app (rails s) the following error is throw:
/Users/xxxx/.rvm/gems/ruby-1.9.2-p290#xxxx/gems/ffi-inline-0.0.4.3/lib/ffi/inline/compilers/gcc.rb:35:in `compile': compile error: see logs at /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log (CompilationError)
It reference the following log file:
g++ -dynamic -bundle -fPIC -L/usr/local/Cellar/tesseract/3.02.02/lib -I/usr/local/Cellar/tesseract/3.02.02/include -o /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.dylib /var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp -llept 2>>/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.log
/var/folders/66/pm_j0lp94gvcj0qnlcnsx9pw0000gn/T/.ffi-inline-501/4239dac38f2a721e0dc5b3750d71ce2e6fa4acb6.cpp:1:10: fatal error: 'leptonica/allheaders.h' file not found
#include <leptonica/allheaders.h>
I followed these two issues:
https://github.com/meh/ruby-tesseract-ocr/issues/3 and https://github.com/meh/ruby-tesseract-ocr/issues/21
It talks about setting ENV vars which i have done. I created a test.rb file in the initalizers folder with the following vars set:
ENV['CFLAGS'] = '-I/usr/local/Cellar/tesseract/3.02.02/include'
ENV['LDFLAGS'] = '-L/usr/local/Cellar/tesseract/3.02.02/lib'
However this makes no difference to the error when starting the app.
I don't understand what it means when it says update the headers. I was wondering if someone could tell me exactly what to do to get this working.
Thanks.
Also had the same error. I solved it by installing the dev packages for tesseract and leptonica.
For debian based systems
sudo apt-get install libleptonica-dev libtesseract-dev
For redhat base systems
sudo yum insall leptonica-devel tesseract-devel
That solved the problem for me.
I've fixed this...
Just in case anyone else has a problem here's exactly how it was fixed in mine:
Firstly had to run both:
brew install tesseract
and
brew install leptonica
Then in the Gemfile NOT in an initializer you have to put both paths to the libraries as env vars:
ENV['CFLAGS'] = '-I/usr/local/Cellar/tesseract/3.02.02/include -I/usr/local/Cellar/leptonica/1.69/include'
ENV['LDFLAGS'] = '-L/usr/local/Cellar/tesseract/3.02.02/lib -L/usr/local/Cellar/leptonica/1.69/lib'
Had this issue (OS X El Capitan). Fixed by downgrading tesseract with
brew uninstall --force tesseract
brew install https://raw.githubusercontent.com/Homebrew/homebrew/8ba134eda537d2cee7daa7ebdd9f728389d9c53e/Library/Formula/tesseract.rb
and updating xcode
xcode-select --install
Related
When I try running rails console I get this error:
/Users/TuzsNewMacBook/.rvm/gems/ruby-2.3.7/gems/bootsnap-1.3.2/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require':
dlopen(/Users/TuzsNewMacBook/.rvm/rubies/ruby-2.3.7/lib/ruby/2.3.0/x86_64-darwin18/readline.bundle, 9):
Library not loaded: /usr/local/opt/readline/lib/libreadline.7.dylib (LoadError)
A quick search got me to this post and I've tried a few things:
brew reinstall postgresql (this is indeed the DB for this project)
and
cd /usr/local/opt/readline/lib
ln libreadline.8.0.dylib libreadline.6.2.dylib
(my version of readline is 8)
and
brew link readline --force
But none of these have fixed it.
I recently added pry-coolline, guard and guard-livereload gems to my project if that makes any difference (rails console loaded fine before those). I'm running on the latest macos.
(Update) I’m using pry rails as my rails console, if that makes any difference.
Any help? Thanks.
the error seems to be thrown when searching for /usr/local/opt/readline/lib/libreadline.7.dylib.
Have you tried to symlink that?
So something like:
cd /usr/local/opt/readline/lib
ln -s libreadline.8.0.dylib libreadline.7.dylib
Just tried that on macOS Mojave, ruby 2.5.3p105 and Rails 5.2.2 and worked.
Reinstalling my Ruby version seems to have fixed it:
rvm reinstall 2.3.7
can you try
cd /usr/local/opt/readline/lib
ln -s libreadline.8.dylib libreadline.7.dylib
you are on the right track but it seems like rails is looking for libreadline.7.dylib and libreadline.7.dylib is not there in the folder.
Yes, the best answer is to reinstall.
You can get the version easily by typing:
ruby -v
With rbenv, the command is i.e.:
rbenv install 2.3.7
with rvm:
rvm reinstall 2.3.7
A very simple solution that doesn't involve rebuilding your RVM gemset OR sym-linking libraries.
Add to your Gemfile:
gem 'rb-readline'
If you are doing bundler groups
group :development do
gem 'rb-readline'
end
Then run
> bundle
Let me know if that doesn't work.
Most often in Ruby-applications, this is caused by gems that have extensions (the gems saying "Building native extensions.."), that are built using a specific version of, in this case, readline.
Basically, there are two solutions:
Either, you can symlink version 8 of the gem, to the version missing. This will work in many cases, but if backwards compatibility is broken, it will not.
Or, if the gem actually supports version 8, you can reinstall that specific gem, or "pristine" it by running gem pristine --all.
EDIT: In scope of your "what I've tried", reinstalling PostgreSQL, is also one of the binaries, built using a specific version, that may also require a rebuild, to work with a system library, such as readline.
Got this issue:
dyld: Library not loaded: /usr/local/opt/mpfr/lib/libmpfr.4.dylib
doing...
cd /usr/local/opt/mpfr/lib/
ln -s libmpfr.dylib libmpfr.4.dylib
did the trick for me for macOS Catalina
Background: This has happened when I tried to install tig, but I think this is a common issue that you may have that you need to manually link the installed software into the right path that another software wants.
If you can not find readline installed on your Mac, you should run
brew install readline
After you installed deadline, brew will ask you to link it. But actually you can not link by running
brew link readline
Even you can not link by running
sudo brew link readline
Mac OS will warn you this is extremely dangerous and stop you to do.
The Latest version of readline is version 8, so you will see the error message like
Library not loaded: /usr/local/opt/readline/lib/libreadline.8.dylib
The brew installed deadline at
/usr/local/Cellar/readline/8.0.4
So you have to manually link it to the place that your software wants by using command ls
ln -s /usr/local/Cellar/readline/8.0.4 /usr/local/opt/readline
Enjoy!
So Ive checked a few answers here but I dont think they can work with a vanilla Mojave mac install. Im using 10.14.4 while I did these:
get homebrew from https://brew.sh
$ brew install coreutils : this installs the gnu coreutils pkg for mac, we want the greadlink from this because macOSX's readlink is not the same as the gnu readlink. Its extremely confusing but such is the life in macland.
$ echo 'alias readlink=greadlink' >> ~/.bash_aliases I found macs readlink to be a bit lacking so I overrode the existing readlink by aliasing greadlink. (you can make this usable by all users by $ alias readlink=greadlink >> /etc/bashrc which will enable every user to be able to use it.
$ ln -s /usr/local/opt/readline/lib/libreadline.8.dylib /usr/local/opt/readline/lib/libreadline.7.dylib I linked the already linked .8. file instead of '.8.0.' file because if it were to get updated to .8.1. then my readlink wont break or miss features on the library. Im pretty sure we will format our macs before 9+ comes out.
I would recommend against manually symlink'ing native libraries. Aas of OS X 10.4, the standard include library path /usr/include is no longer used and is locked by SIP (making it difficult to move things to).
Apple ships a “legacy installer” for you to be able to install the headers in the “old location”, which will also resolve your path to correctly find headers installed via brew.
cp /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg ~/Desktop && open ~/Desktop/macOS_SDK_headers_for_macOS_10.14.pkg`
See here for a detailed write-up on what is going on.
My problem was just the same when running lftp.
Just running brew upgrade has solved my problem, as it has updated (among others):
readline 8.0.0_1 -> 8.0.1
lftp 4.8.4 -> 4.8.4_2
I am using the command in terminal
> rbenv install 2.0.0-p247
It runs the command and this is the output:
> Downloading ruby-2.0.0-p247.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.0/ruby-2.0.0-p247.tar.bz2
Installing ruby-2.0.0-p247...
But the error message I get is
> BUILD FAILED (OS X 10.11.2 using ruby-build 20160130)
Inspect or clean up the working tree at /var/folders/tl/8vtvj5l967v6qjh162g3k2c40000gn/T/ruby-build.20160221132135.9296
Results logged to /var/folders/tl/8vtvj5l967v6qjh162g3k2c40000gn/T/ruby-build.20160221132135.9296.log
Last 10 log lines:
ERROR: Ruby install aborted due to missing extensions
Configure options used:
--prefix=/Users/BryanSingh/.rbenv/versions/2.0.0-p247
--with-libyaml-dir=/usr/local/opt/libyaml
--with-openssl-dir=/usr/local/opt/openssl
--with-readline-dir=/usr/local/opt/readline
CC=clang
CFLAGS= -O3 -Wno-error=shorten-64-to-32
LDFLAGS=-L/Users/BryanSingh/.rbenv/versions/2.0.0-p247/lib
CPPFLAGS=-I/Users/BryanSingh/.rbenv/versions/2.0.0-p247/include
I tried using Google to find this error. But had no luck. Any help would be appreciated
The error was caused by homebrew being unable to locate the extensions properly after an OS upgrade.
You'll need to update Xcode and then reinstall Ruby.
I had faced the similar issue today.
I solved it by following instructions from RailsApp project
Click here and go to the section "Install RVM"
After installing rvm
$ rvm get stable --autolibs=enable
and follow the rest instructions as mentioned in the RailsApp project.
I have application using Rails 4 and Ruby 2. I started to use mongoid-paperclip and it is working fine.
I installed ImageMagick-6.8.6-8. I added Paperclip.options[:command_path] = "/usr/local/bin/" in development.rb. And I have
mongoid-paperclip
rmagick (~> 2.13.2)
cocaine (0.5.1)
When I added "has_mongoid_attached_file :avatar, :styles => { :small => "160x160!" }" I started to get this error: Paperclip::Errors::NotIdentifiedByImageMagickError: Paperclip::Errors::NotIdentifiedByImageMagickError
Any help please I spent hours and hours without any luck.
NOTE: This solution is for OS-X machines and imagemagick installed via "brew"
Some of my students (I teach Rails at a dev bootcamp) had the exact same problem on their Mac OS-X machines. And, the following solution fixed them all.
The Cause
The cause of the problem is that jmagemagick is compiled using a wrong GCC compiler in your box. Although it probably has compiled into an executable (binary), however, when it runs, it fails due to linking errors (it's trying to dynamically load some dependencies, ie, libraries).
The Solution
You need to reinstall imagemagick using a correct GCC. If you have a Mac, please, follow the instructions below:
Open XCode program (if you don't have it, install it)
Go to Preference and open "Download" tab
Download "Command line tool"
After download is complete, open a terminal
Run "brew reinstall imagemagick"
That should do it!
When using brew install imagemagick, it seems to install a precompiled binary that lacks TIFF support. Use this to install ImageMagick with proper TIFF support:
brew install libtiff
brew reinstall imagemagick --with-libtiff
(Credits to Groveriffic: https://stackoverflow.com/a/13150641/235297)
1- I have the same issue, and I solved it, when i configure the dynamic linker run-time bindings to create the necessary links and cache to the most recent shared libraries using the ldconfig command.
So you need to use the following command:
sudo ldconfig /usr/local/lib
Actually, I advice to re-install imagemagick using steps at how-to-install-image-magick-and-setup-paperclip.
2- You need to add the following code in development.rb file:
Paperclip.options[:command_path] = "/usr/local/bin/"
Running these two commands did the trick for me. Remember to use the --force since libtool is keg-only
brew install libtool --universal
brew link libtool --force
I'm getting this error when I try to run any brew command.
Holger-Sindbaeks-MacBook-Air:~ holgersindbaek$ brew help
-bash: /usr/local/bin/brew: /usr/bin/ruby: bad interpreter: No such file or directory
I have absolutely no idea on how to fix this and been searching for a long time without answer.
I got this error (much the same):
/usr/local/bin/brew: /usr/local/Library/brew.rb: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby: bad interpreter: No such file or directory
/usr/local/bin/brew: line 26: /usr/local/Library/brew.rb: Undefined error: 0
and fixed by the solution below:
Open brew.rb:
$ sudo vim /usr/local/Library/brew.rb
Change the first line's 1.8 to Current:
Before:
#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -W0
After:
#!/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby -W0
Then brew works for me. Hope it helps if any other one got this issue. :)
If you get the error
Homebrew requires Leopard or higher. For Tiger support, see:
https://github.com/mistydemeo/tigerbrew
change the MACOS check from <10.5 to <10.
Tip by #TimCastelijns:
10.5 doesn't work because in comparison, it's higher than 10.10 (.1 vs .5). I added a check (and MACOS_VERSION != 10.10) instead of lowering from 10.5 to 10.
What you are getting means that Homebrew has not been able to locate the Ruby interpretter at the specified location.
Install Apple Developer Kit (comes with Xcode) which should be available to you as an optional install (or you can simply download it from Apple). This will install the Ruby interpreter for you.
In case you already have Xcode installed, this means that one of these things is happening:
You have a broken Ruby installation
You have more than one Ruby installation
Your installation has not been configured properly.
To identify if this is the first case, you can run ruby and see if you get any response.
If you don't, your installation is broken and you need to reinstall it. If you do, you then run which ruby. This should give you the absolute path to your Ruby executable. If this is anything other than /usr/bin/ruby then homebrew (and a bunch of other programs) will not be able to find it.
In case you have not ever tampered with your Ruby installation, you can check to see if /usr/bin/ruby already exists or not: cat /usr/bin/ruby. If you get No such file or directory, then you can easily create a symbolic link to your Ruby installation. Assuming the output of which ruby to by /usr/local/bin/ruby, you create the symbolic link this way: sudo ln -s /usr/local/bin/ruby /usr/bin/ruby and all should be well.
If there is a file at that location, you can run file /usr/bin/ruby to see if it's a real file, a symbolic link, or a corrupted file. If it is a symbolic link, your installation should be working, and since it's not, it probably is either a corrupted symlink or it's a bogus file.
You can remedy that by first deleting it (sudo rm /usr/bin/ruby) and then creating a new symlink to the correct location (sudo ln -s /usr/local/bin/ruby /usr/bin/ruby).
If non of the above works, you should consult the homebrew team after a clean install of Xcode and removing any traces of a Ruby installation on your system.
EDIT
Alternatively, as pointed out by the other answers, the issue might be because of a bad ruby version in your Homebrew settings.
A quick fix might be updating your Homebrew:
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
If this does not help, you might want to get your hands dirty and manually fix the problem by:
Editing brew.rb from /user/local/Library/brew.rb
Changing /1.8/ to /Current/ in the first line, which will cause the hashbang to point to the current Ruby version as the executor
If this does not help, either, you can also modify the MACOS check and change it from 10.5 to 10 to avoid the infamous "Homebrew requires Leopard or higher" error.
DISCLAIMER
A bunch of thanks to other contributors in the answers below and their commenters. I am not committing plagiarism, simply aggregating the answers into one integrated article to help others.
Fix:
sudo gem install cocoapods
At the risk of oversimplifying things, try running
gem install bundler
I was transitioning my Ruby environment from RBENV to RVM and it worked for me.
This happened because I needed to update brew - in the updated version it already uses Current ruby
cd /usr/local
git pull -q origin refs/heads/master:refs/remotes/origin/master
This solved the problem
You need to change the path for Ruby.Framework
I solved it with commands as mentioned.
brew install cocoapods --build-from-source
brew link --overwrite cocoapods
If you have a lower version below Xcode 11, you have to remove it before you use the above commands.
Reference: Ruby Framework issue
None of the above worked for me, so I kept browsing and found this answer,
https://stackoverflow.com/a/24225960/1359088
which did fix brew for me. He says in step 1 to install XCode 6 command line tools, but doesn't say how; use this command:
xcode-select --install
I got the same issue when updated to MacOSX High Sierra & using Xcode 9 with that. High Sierra update ruby gem to version 2.3 but xcpreety command of Xcode 9 still using Ruby 2.0 which is unable to find now & gives bad interpreter.
Just go to Terminal & run
sudo gem install xcpretty
Restart Xcode & do fresh clean build it works for me.
Hope it helps!!!
After upgrading to macOS High Sierra, get it fixed with following commands:
sudo gem install cocoapods
In my case seems like fastlane installed incorrectly with brew install fastlane system didn't write correct path to fastlane. I fixed it with alias fastlane=~/.fastlane/bin/fastlane
I solved it with commands as mentioned.
1.) Uninstall your GEM.
gem unistall GEM
2.) Then Install your GEM.
sudo gem install GEM -n /usr/local/bin
I got bad interpreter: No such file or directory error when used xcpretty and xcpretty-travis-formatter on upgraded MacOS.
To solve it
gem install xcpretty
gem install xcpretty-travis-formatter
That is why I can recommend you to reinstall failed component gem install <name>
#For example error looks like
/usr/local/bin/xcpretty-travis-formatter: /System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby: bad interpreter: No such file or directory
#use
gem install xcpretty-travis-formatter
I've had ImageMagick, RMagick, & PaperClip working properly with everything setup including the config Paperclip.options[:command_path] in production.rb file.
All of a sudden I've started getting the following error:
Could Not Run The `Identify` Command. Please Install ImageMagick.
I've tried everything. I've reinstalled ImageMagick, etc. but no avail.
Any help would be greatly appreciated.
From a terminal, run the following command:
sudo apt-get install imagemagick
You need to change the files production.rb and development.rb which are in:
config/environments:
# Paperclip config:
Paperclip.options[:image_magick_path] = "/opt/ImageMagick/bin"
Paperclip.options[:command_path] = "/opt/ImageMagick/bin"
Just add those two lines just before the last line and restart the server.
In MacOSX system, if you are using another location, just put the right PATH there.
For Mac users: just run the command brew install imagemagick.
You can type
which convert and which identify
to check whether imagemagick is installed properly.
In my case, which convert returns /usr/local/bin/convert but identify not found.
I used brew install imagemagick before, so I run it again and return imagemagick already installed, it's just not linked.
Finally got the point, brew link imagemagick(or brew link --overwrite imagemagick)
Don't forget to add the Paperclip.options[:command_path] = "/usr/local/bin/" to your config/environment.rb file.
I had a same issue. This is what worked for me. From terminal, first:
sudo apt-get update
Then:
sudo apt-get install imagemagick
I had this issue, when I had started rails server from my rubymine ide. It seems it does not load your .zshrc (in my case, could also be valid for .bashrc). So some environment variables that make imagemagick work with dvm were not set. For example:
export PATH=$HOME/local/imagemagick/bin:$PATH
export LD_LIBRARY_PATH=$HOME/local/imagemagick/lib:$LD_LIBRARY_PATH
Once I restarted from my terminal, the error was gone.
I had the same problem. It was caused by https://github.com/thoughtbot/paperclip/issues/1709
This is how I solved this issue:
sudo apt install imagemagick
For Cent OS users:
sudo yum install ImageMagick ImageMagick-devel
will do the job