These are chat archives for stephan-nordnes-eriksen/ruby_ship

23rd
Mar 2016
David Ohayon
@ohwutup
Mar 23 2016 13:29 UTC
hey!
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:30 UTC
hey
David Ohayon
@ohwutup
Mar 23 2016 13:31 UTC
so I was curious how you are using this? i have been experimenting with phusion/traveling-ruby for a couple weeks and it is a really complex way of doing things and your scripts are much simpler.
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:31 UTC
I have used this to bundle ruby into a distributable application which I was keen on running some ruby code within
David Ohayon
@ohwutup
Mar 23 2016 13:32 UTC
nice. so that is exactly what i am trying to do, but it is a command line app that i am trying to bundle. and like i mentioned in that github issue it works when i call it from within the ruby_ship directory, but not from outside.
im not so familiar about the ruby compilation process with all of the paths involved but i was wondering if you had ever tried to explore getting that to work?
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:34 UTC
yeah
i commented on the github issue
I don't know if you saw that
the deal is that on osx the dylibs are dynamically linked based on the root folder, so you need to run those binaries from the context of the ruby_ship folder
I am not entirely sure how this works on linux though because the same procedure isn't needed there, or is somehow handled without my influence
David Ohayon
@ohwutup
Mar 23 2016 13:42 UTC
ah, okay cool. yeah i am only working on OS X
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:44 UTC
From what language are you calling ruby_ship?
David Ohayon
@ohwutup
Mar 23 2016 13:44 UTC
just from the command line
i have a command line gem that i want to use
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:44 UTC
ahh.. I see
David Ohayon
@ohwutup
Mar 23 2016 13:44 UTC
but it needs to be called from the working directory that it needs
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:44 UTC
what type of error are you getting?
You can set the working directory if you get the ruby to run at all
or you can wrap it in a thin bash-script which sets working directory
David Ohayon
@ohwutup
Mar 23 2016 13:45 UTC
/Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require': dlopen(/Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle, 9): Library not loaded: bin/shipyard/darwin_ruby/dylibs/libssl.1.0.0.dylib (LoadError) Referenced from: /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle Reason: image not found - /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/x86_64-darwin15/openssl.bundle from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/openssl.rb:13:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/excon-0.45.4/lib/excon.rb:6:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/fastlane_core-0.37.0/lib/fastlane_core/update_checker/update_checker.rb:1:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/fastlane_core-0.37.0/lib/fastlane_core.rb:6:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/fastlane-1.66.0/lib/fastlane.rb:18:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/2.3.0/rubygems/core_ext/kernel_require.rb:55:in `require' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/lib/ruby/gems/2.3.0/gems/fastlane-1.66.0/bin/fastlane:6:in `<top (required)>' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/bin/fastlane:23:in `load' from /Users/dohayon/Twitter/git/ruby_ship/bin/shipyard/darwin_ruby/bin/fastlane:23:in `<main>'
ah, that didn't work well, one sec
Screen Shot 2016-03-23 at 9.45.52 AM.png
yeah, i think you're right about the bash script
so if i run the build script with other versions, is the darwin_ruby.sh shim always pointing to the most recent version?
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:47 UTC
Not sure I understand that last question.
There is only one version of ruby "installed" at a time
David Ohayon
@ohwutup
Mar 23 2016 13:48 UTC
ah okay
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:48 UTC
and by the way, i just updated the osx ruby version to 2.3.0
David Ohayon
@ohwutup
Mar 23 2016 13:50 UTC
oh nice! thanks! we want to be able to reliably build new versions as they come out, i am going to give 2.4.0-dev a shot
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:51 UTC
cool
I found that i needed to do a brew install libffi and then 2.3.0 build successfully
However, i believe you will have a hard time "reliably building new versions" as the dev dependencies might change from version to version
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:57 UTC
The error you are getting is related to linking problems. You need to run the auto_relink_dylibs.rb
David Ohayon
@ohwutup
Mar 23 2016 13:58 UTC
nah, calling it from outside the directory it always fails after doing that
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 13:58 UTC
I suspect it crashed for some reason. It is supposed to run automatically when you build a new version
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:07 UTC
What command are you running that is causing this?
David Ohayon
@ohwutup
Mar 23 2016 14:15 UTC
path/to/ruby_ship/bin/shipyard/darwin_ruby/darwin_<myscript>.sh <arguments>
where darwin_<myscript>.sh is a shim to my script based of your shims with other things like darwin_gem.sh
but i get the sam error if i do path/to/ruby_ship/bin/shipyard/darwin_ruby/darwin_ruby/bin/<my_script> <arguments>
if i do either of those from outside the root ruby_ship directory i get the error
when I'm inside the ruby_ship directory i get that ssl crash
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:17 UTC
Yeah. I am getting the same thing. Trying to see if I can manipulate workingdirectory
David Ohayon
@ohwutup
Mar 23 2016 14:17 UTC
oh that would be amazing
I'm curious to know how you would do that too
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:17 UTC
I see that I have tried to add this already
if you have a look at the line in ruby_ship.sh: DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
That should in theory change working directory, but apparently it does not do that correctly
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:22 UTC
Ok, I think I have something here
It is a bit quirky though, but try to swap out your ruby_ship.sh with this:
OS="unknown"
if [[ "$OSTYPE" == "linux"* ]]; then
    OS="linux"
elif [[ "$OSTYPE" == "darwin"* ]]; then
    OS="darwin"
elif [[ "$OSTYPE" == "cygwin" ]]; then
    OS="win"
elif [[ "$OSTYPE" == "win32" ]]; then
    OS="win"
elif [[ "$OSTYPE" == "freebsd"* ]]; then
    OS="freebsd"
else
    echo "OS not compatible"
    exit 1
fi

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$( dirname "${BASH_SOURCE[0]}" )/../"
SSL_CERT_FILE="${DIR}/shipyard/cacerts.pem" "${DIR}/shipyard/${OS}_ruby.sh" "$@"
Quirk;
Your parameters will needs to be absolute paths or relative to the ruby_ship folder
eg: This will not work: my_folder/path/to/ruby_ship/bin/ruby_ship.sh ./my_script_in_my_folder.rb
David Ohayon
@ohwutup
Mar 23 2016 14:25 UTC
right, but i am doing my_folder/path/to/ruby_ship/bin/shipyard/my_wrapper.sh arguments
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:26 UTC
So you essentially have your own ruby_ship.sh file?
or are you using the ruby_ship.sh file within your wrapper?
David Ohayon
@ohwutup
Mar 23 2016 14:27 UTC
yeah, i copied the ruby_ship_gem.sh and modified it to call my script
my executable*
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:27 UTC
Ok
I believe a better approuch could be to wrap the provided wrappers in stead
David Ohayon
@ohwutup
Mar 23 2016 14:28 UTC
how can i call a ruby gem's command line executable using those wrappers though
thats what I'm a bit confused about
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:29 UTC
The wrappers work exactly like the normal commands
so ruby_ship_gem.sh works exactly the same as gem
so you can do: ruby_ship_gem.sh install whatever
the only reason why those wrappers exist is that there is some hustling around with environment variables that forces stuff to work portably
and it also routes to the right os-variation of this
David Ohayon
@ohwutup
Mar 23 2016 14:36 UTC
right, so then how would you call one of those gems from outside the directory?
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:37 UTC
Yeah.. Now I see where you are going
Have a look at for instance darwin_bundler.sh
and ruby_ship_bundler.sh
David Ohayon
@ohwutup
Mar 23 2016 14:38 UTC
yup
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:38 UTC
This is essentially what you want to emulate
David Ohayon
@ohwutup
Mar 23 2016 14:38 UTC
right. yeah, so maybe i am doing something wrong there, but i tried to follow that same pattern
ill give it another shot though and let you know!
thank you so much for your help
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:38 UTC
And you need to do the same thing as I did in the ruby_ship.sh above, namely setting the correct working directory: cd "$( dirname "${BASH_SOURCE[0]}" )/../"
But you will get the same quirk. If the arguments are relative paths, then stuff won't work right
David Ohayon
@ohwutup
Mar 23 2016 14:44 UTC
thats cool, the arguments are normally just commands to be executed, but we can expand relative paths in the script right to get their absolutes
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 14:45 UTC
I am trying to find a reliable way to expand relative paths, but can't find a good *nix solution
if you have one, please let me know, and I can add it to all the other wrappers as well
David Ohayon
@ohwutup
Mar 23 2016 14:50 UTC
what do you mean by a "nix" solution?
i was actually just referring to, in my gems, i can expand the path arguments
Stephan Nordnes Eriksen
@stephan-nordnes-eriksen
Mar 23 2016 17:42 UTC
unix
(and the like)