How to setup rake to compile mruby gems? - rake

I am trying to build the example gem from here following the mruby documentation for building gems.
I'm on a Mac OS Catalina, and I have installed RVM to manage my installation mruby. Right now which ruby returns /Users/mdorier/.rvm/rubies/mruby-2.0.1/bin/ruby so I can see that mruby is used.
The example gem above has an mrbgem.rake file, so even though the documentation doesn't explain how to build the gem, I suppose rake should be invoked in that directory. I didn't have rake installed, so I tried to install it with gem install rake, but it seems that Mac OS's native gem executable in /usr/bin got invoked, apparently installing the normal ruby's rake gem. When I call that rake, it doesn't find a Rakefile in the directory. If I specify rake -f mrbgem.rake, it tells me NameError: uninitialized constant MRuby.
I see that mruby doesn't have a gem command but seems to have a mgem that can be installed with gem. I installed it. I see that there is a mruby-rake mgem available, which I activated using mgem add mruby-rake, but it doesn't change what the rake command points to.
Can someone explain how I can install and use the proper rake command to build this mruby gem?

Related

How can I solve this error and install cocoapods?

In my terminal I use:
sudo gem install cocoapods
My terminal gives the error shown below. How can I solve this? I have tried a few variations and I cannot get it to work.
Building native extensions. This could take a while...
ERROR: Error installing cocoapods:
ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2/ext/ffi_c
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20200518-1427-ajbhbt.rb extconf.rb
mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/include/ruby.h
You might have to install separate package for the ruby development
environment, ruby-dev or ruby-devel for example.
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/ffi-1.12.2 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/ffi-1.12.2/gem_make.out
Agree with Vinayaka and Bryan you're missing some ruby header files and it looks like they're required. Not sure about your environment setup but it may help to just reinstall the latest Xcode from scratch.
Also, I've had some recent problems with Cocoapods installed via terminal. The terminal installs the latest build of Cocoapods. If you're looking for something stable then maybe try the Cocoapods app. It's clunky and it can't read pod files from the latest version of Cocoapods (so you'll have to regenerate any existing podfiles) but its easier to work with especially for those who prefer a graphical environment.
We need to install Xcode's developer tools. The easiest way to do this is through terminal .
xcode-select --install
Later, if there are any write permission issues, use the below code.
sudo gem install cocoapods -n /usr/local/bin/..
P.S: -n specifies the directory where binaries are located.
Please try with
brew install cocoapods

Installing redmine_contacts plugin for bitnami_redmine

I am trying to install redmine_contacts plugin for my redmine 2.2.3.0 (which is installed using BITNami installer), as in readme.rdoc:
Copy redmine_contacts plugin to {RAILS_APP}/plugins on your redmine path
Run bundle install --without development test RAILS_ENV=production
Run rake redmine:plugins NAME=redmine_contacts RAILS_ENV=production
The first two steps was successful, but last executing last command, following error would occur:
(in /home/.../redmine-2.2.3-0/apps/redmine/htdocs)
Could not find sprockets-2.2.1 in any of the sources
Run bundle install to install missing gems.
To see if the sprockets library is installed by executing command: #bundle show sprockets, it shows a newer version of this library is installed:
/var/lib/gems/1.8/gems/sprockets-2.2.2
I think somehow the BitNami version of gem which is installed is not compatible with the sprockets-2.2.2 on the system and it requires 2.2.1. Maybe you should change to that version.
Try something like:
gem install sprockets -v 2.2.1

Why can't TeamCity run this Rake build using Albacore?

I created a build script using Rake & Albacore which builds a solution and executes unit tests. I am trying to set it up in TeamCity. I am getting this error.
Cannot start build runner: If you wan't to use bundler please install
it at first. The gem wasn't found in Gem paths of Ruby SDK with
interpreter: 'C:\Ruby187\bin/ruby.exe'.
Hide stacktrace
jetbrains.buildServer.agent.rakerunner.RakeTasksBuildService$MyBuildFailureException:
If you wan't to use bundler please install it at first. The gem wasn't
found in Gem paths of Ruby SDK with interpreter:
'C:\Ruby187\bin/ruby.exe'. Gem paths: C:/Ruby187/lib/ruby/gems/1.8
C:/Users/af/.gem/ruby/1.8
I added one parameter, where Albacore is installed. But, I am still getting the error.
GEM_PATH=C:\Ruby187\lib\ruby\gems\1.8\gems\albacore-0.3.4\albacore.gemspec
Ok finally was able to resolve the problem. I simply created a batch file that executes the rake task and instead of using "Rake Build Step" in Team city; used the command line build step and executed the batch file. It also gives me complete log of all the build steps, tests run etc.
Hopefully this will help someone else too. You don't need to setup a Rake Build Step as it turns out.
It's not clear that Albacore was missing. The error message indicates that TeamCity cannot find Rake itself!
Cannot start build runner
What was the exact Rake task configuration? Specifically the Ruby Interpreter configuration section? You can tell TeamCity exactly which Ruby to run, which will affect which gems are available (and Rake is just a gem).
It looks like you have a Ruby 1.8.7 installed and that you must have installed Albacore
cmd> gem install albacore
Do you also have Rake installed? In Ruby 1.8.7, the Rake gem was not included by default. You can list the machine's installed gems by
cmd> gem list --local
You'll should install Rake.
cmd> gem install rake
I'm not actually sure how you ended up getting this to work. What's the contents of the batch file? Do you have any other Ruby/Rake installed?

Why is bundler not able to install rake even though rake appears to be present?

I'm having some trouble with rbenv and bundler. When I bundle install on my app, I get an error saying that an error occurred while installing Rake.
I'm thinking this has something to do with rbenv not pointing to the write path for gems -- but I'm not positive.
Why is bundler not able to install rake when rake appears to be present?
Console Output
deploy#telemed-test:/u/apps/telemed_solutions/current$ bundle install
Fetching gem metadata from http://rubygems.org/.......
Fetching gem metadata from http://rubygems.org/..
NoMethodError: private method `open' called for Gem::Package:Class
An error occured while installing rake (0.9.2), and Bundler cannot continue.
Make sure that `gem install rake -v '0.9.2'` succeeds before bundling.
deploy#telemed-test:/u/apps/telemed_solutions/current$
deploy#telemed-test:/u/apps/telemed_solutions/current$ rbenv version
1.9.3-p125 (set by /home/deploy/.rbenv/version)
deploy#telemed-test:/u/apps/telemed_solutions/current$ gem list
*** LOCAL GEMS ***
bigdecimal (1.1.0)
bundler (1.1.3)
io-console (0.3)
json (1.6.6, 1.5.4)
minitest (2.12.1, 2.5.1)
rake (0.9.2)
rdoc (3.12, 3.9.4)
It might be time to upgrade rubygems. Some of the specification files may be calling rubygems methods that don't exist in your version.
Run gem --version to check your current version.
And gem update --system to upgrade to the latest.

Having trouble installing the PG gem

I'm trying this, as the docs say:
gem install pg --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
ERROR: While executing gem ... (OptionParser::InvalidOption)
But, that's obviously not working. Can anyone spot an error?
The example that you're linking to says this:
gem install -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config
#-----------^^
Note the -- in there that you're not using. I suspect that gem is trying to parse the --with-pg-config as an option to gem rather than an option to the gem itself. Just a plain -- in an option list means "stop parsing options here" so try one of these:
gem install -- pg --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
gem install pg -- --with-pg-config=/opt/local/lib/postgresql90/bin/pg_config
One of those should keep gem from trying to interpret --with-pg-config as a gem option and get it down to the pg gem itself.
Not sure if the other answer works, but I thought I'd point out that the instructions here did work if you're using bundler to manage gems:
http://devblog.vworkapp.com/post/403869225/install-pg-gem-via-bundler-on-osx-snow-leopard
install postgres from Mac Ports
sudo port install postgres84
Include the postgres binaries in the PATH environment variable
export PATH=/opt/local/lib/postgresql84/bin:${PATH}
Then run bundle install with the all-important arch flag
env ARCHFLAGS="-arch x86_64" bundle install
Caveats: Your ARCHFLAGS may be something like i386 and not x86_64, depending on your local environment (and these instructions are obviously installing an older postgres -- I did sudo port install postgresql90).