My app
I have a Mac app that uses AsciiDoctor under the hood to generate PDF and ePUB files. I use the Process class (formerly NSTask) to run the AsciiDoctor commands.
What I want
I want people to be able to use my app without having to manually install the AsciiDoctor Ruby gems from the Terminal.
Copying the gems to the app bundle
My first attempt was to install the AsciiDoctor gems in a custom folder on my Mac and add a Copy Files build phase to my Xcode project to copy the folder with the gems into the app bundle. Adding the gems to the app bundle worked on my machine but didn't work well on other machines. I couldn't create PDF or EPUB files on systems with a different version of Ruby than the version on my Mac that I used to install the gems. On a macOS 10.13 virtual machine, I was able to create a PDF file but not an EPUB file.
Installing the gems in the Application Support folder
My second attempt was to install the gems in my app's Application Support folder the first time someone launches the app. But that didn't even work on my machine. When I used the launch path usr/bin/ruby for the command-line process and the following argument list:
let argumentList = ["gem", "install", "-i", gemFolder.path, gem, "--pre"]
Where the variable gemFolder.path is the path to the Application Support folder and the variable gem is either "asciidoctor-pdf" or "asciidoctor-epub3".
I got the following error message from standard error when running the command-line process:
/usr/bin/ruby: No such file or directory -- gem (LoadError)
When I used the launch path gem or gem install, calling the Process method run threw an exception. Here are the error messages the exception threw.
Error Domain=NSCocoaErrorDomain Code=4 "The file “gem” doesn’t exist." UserInfo={NSFilePath=gem}
Error Domain=NSCocoaErrorDomain Code=4 "The file “gem install” doesn’t exist." UserInfo={NSFilePath=gem install}
Question
How do I include the AsciiDoctor gems in my app so people don't have to manually install the gems? Do I need to create an installer for the app?
Related
I'm trying to install jekyll based on instructions here (via rbenv): https://gist.github.com/r-brown/a0b50d56cfb3596e0d17
Before the "bundle install" step, it states:
go to the project folder
However, I'm new and simply truly confused as to what this refers to? I don't actually have a project folder right now, because I am merely in the process of installing jekyll?
Or is that referring to a specific location based on the earlier installation steps?
I attempted to skip this step and directly input bundle install, but that yielded this error
"Could not locate Gemfile".
Referring to this post: Could not locate Gemfile was unfortunately not useful as no one explicitly stated what "project folder" entails...
Why do you want to use jekyll? Usually you would use it as part of a project - which probably entails writing the line:
gem 'jekyll'
...inside the Gemfile of your project. And then, to install the library (along with all other dependencies, you can run bundle install.
This is why the next line of the guide talks about running the command: bundle exec jekyll serve ... -- because the author is assuming that you have a project set up.
However, if you just want to install the gem globally (i.e. not within the context of a project), then you don't need to do anything with bundle. Just run:
gem install jekyll
Update:
Mainly, I need a .bat file to be placed in RUBY_HOME/bin, similar to how rails.bat gets placed in bin when the Rails gem is installed
I'm building a gem that can be used for generating automation test frameworks for testing web application written in any language, with any framework.
I need one file within my gem to be run every time the gem is installed. This file generates either a .bat or .sh file.
I have already built this script and it works great, I just need it be run each time the gem is installed using bundler. Is this possible?
I have Textmate 2.0-beta.7.1 on Mac OSX v10.9.5
I would like to write ruby scripts so I installed the ruby bundle.
However when I try to run a script I get the error:
env: ruby18: No such file or directory
so having found that the path to my ruby installation using
which ruby
/usr/bin/ruby
I made sure this was in my variable paths in Textmate>Preferences> Variables so that it under the PATH variable name it looked like this:
$PATH:/usr/bin/ruby:/opt/local/bin:/usr/local/bin:/usr/texbin:/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
I then tried to run my ruby script again and I got the same error. I have googled for hours and the only resolution seems to be the addition of the ruby path to $PATH as I have done above so I'm a bit confused as to my I cant proceed
Make sure you have not disabled the Bundle Support, TextMate, Text, Source, or SCM bundles in the Bundles tab of Preferences; these are all required bundles to support basic bundle functions.
I wanted to install the rspec-rails gem with ruby 1.9.3 on windows 7. I got some errors saying that some json libraries could not be installed. So, I used the instructions below to solve it.
Source = The 'json' native gem requires installed build tools
Download [Ruby 1.9.3][2] from [rubyinstaller.org][3]
Download DevKit file from [rubyinstaller.org][3]
For Ruby 1.9.3 use [DevKit-tdm-32-4.5.2-20110712-1620-sfx.exe][4]
Extract DevKit to path C:\Ruby193\DevKit
Run cd C:\Ruby193\DevKit
Run ruby dk.rb init
Run ruby dk.rb review
Run ruby dk.rb install
To return to the problem at hand, you should be able to install JSON (or otherwise test that your DevKit successfully installed) by running the following commands which will perform an install of the JSON gem and then use it:
gem install json --platform=ruby
ruby -rubygems -e "require 'json'; puts JSON.load('[42]').inspect"
When I execute the above first step, I get the error -
C:\Ruby193\DevKit>gem install json --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile
make
'make' is not recognized as an internal or external command,
operable program or batch file.
Gem files will remain installed in C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection.
Results logged to C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
I am trying to solve the above error now -
'make' is not recognized as an internal or external command, operable program or batch file.
using make is not recognized as an internal or external command - Qt SDK - Windows
If someone already knows how to fix this, then please help me. I have been struggling to install gems and I am failing for so many days. I am wondering if ruby is so difficult.
The DOSKEY approach failed !!!
I did this - Install Mingw and installed all its developer tools and base stuff. Then added C:\MinGW\bin to environment variables to find mingw32-make.exe. Then, I ran the DOSKEY make=mingw32-make followed by the ruby command. I got the same error. I am guessing that the ruby code is spawning off a hidden cmd window and thats why the command is not working. DOSKEY is valid only in the cmd window in which you run it.
Next step - Not so nice, but, I'll change mingw32-make.exe to make.exe and see.
Failed again with a new error -
Temporarily enhancing PATH to include DevKit... Building native
extensions. This could take a while... ERROR: Error installing json:
ERROR: Failed to build gem native extension.
C:/Ruby193/bin/ruby.exe extconf.rb creating Makefile
make generating generator-i386-mingw32.def compiling generator.c In
file included from generator.c:1:0: ../fbuffer/fbuffer.h:5:18: fatal
error: ruby.h: No such file or directory #include "ruby.h"
^ compilation terminated. Makefile:204: recipe for target 'generator.o' failed make: *** [generator.o] Error 1
Gem files will remain installed in
C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1 for inspection. Results
logged to
C:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.8.1/ext/json/ext/generator/gem_make.out
What do I do now ?
Most of the Ruby gems are developed for Unix and require some extra tools to make it work on Windows.
In order to install those gem in Windows, you need Ruby DEVELOPMENT KIT from the download link (choose the correct installer based on your Ruby version).
Extract the installation to some permanent location. In my system, it is C:\RubyDevKit.
Open command prompt and cd to the extracted location and execute the following commands
cd C:\RubyDevKit
ruby dk.rb init
ruby dk.rb install
devkitvars.bat
The last command is what I missed initially and took sometime to figure out. Now try installing your gem; it worked for me.
Additional Information
The Ruby Development Kit has a component called MinGW which is used to run Unix command on Windows.
The below error, in my case, was Ruby Development Kit not added to the system path variable
make
'make' is not recognized as an internal or external command,
operable program or batch file.
The command devkitvars.bat adds the Development Kit to the system path.
Try installing gnuwin-32 make and then change environment variable PATH to point to C:\Program Files (x86)\GnuWin32\bin
Ruby installation wizard asks you "Add Ruby executables to your PATH", for me, easy solution is to uninstall ruby and install again, this time checking the check box "Add Ruby executables to your PATH"
With the latest version of Ruby 2.4.2, the dev kit is included in the installation so you don't need to follow the separate install instructions. Just uninstall existing ruby and reinstall the new one here https://rubyinstaller.org/downloads/.
Once finished, it'll open up a command prompt on which you need to select option 3 to include the dev kit. However, at the time of writing it's so buggy and you may or may not have issues installing.
I have tried to setup ruby on rails on a windows system, although there are one click installers that install ruby itself and rails, many of the gems rely on a posix based operating system to be compiled, thus making it near impossible to do actual work on windows.
My advise would be to get yourself a linux system, perhaps unbuntu on your system and dual boot, or get a virtual pc software, like this one, or any of the other options, and try installing ruby from there.
I installed Ruby on Windows via RubyInstaller, with the associated DevKit.
I'm trying to run various scripts (mainly Jekyll), and I'm getting all sorts of errors about paths. For instance:
...cannot load such file -- redcarpet.so (LoadError)
Or:
...cannot load such file -- 2.0/redcloth_scan (LoadError)
Specifically, in both those cases, I'm trying to run "redcloth.bat" and "redcarpet.bat" in the bin directory of the Ruby directory.
I feel like I'm missing something basic with paths. Note that this has never worked -- I installed the RubyInstaller, then the DevKit, then the Jekyll gem...and this is what happened.
Is there something basic about this installation that I failed to set?
We ran into the RedCloth side of this error today.
We started with this error
How to install RedCloth on Windows?
What we found was we had installed the mswin32 version of RedCloth, we first got the no such file to load.
We then went to our
C:\ruby200/lib/ruby/gems/1.9.1/gems/RedCloth-mswin32
Directory , added the 2.0 file and copied the redcloth_scan.so file into the 2.0 directory.
We started getting another error that was similar.
We decided we would just uninstall the precompiled version of the gem, and start with the normal RedCloth-2.4.9.gem to be compiled locally with devkit.
Once this was installed, we again went to the lib dir for the gem.
CD C:/ruby200/lib/ruby/gems/1.9.1/gems/RedCloth-2.4.9/lib
We created a 2.0 directory
We then copied the file redcloth_scan.so file into the 2.0 directory and we no longer had the error. The server came up fine and we