-
Notifications
You must be signed in to change notification settings - Fork 0
Ruby
In Ubuntu + Nix
For example https://github.com/licensee/licensee
It requires native extension rugged. These depending C extensions are an annoy issue for using Ruby. See https://github.com/licensee/licensee/issues/66
On the other hand, nixpkgs having licensee as a package. However it is not the latest.
licensee provides Dockerfile, however it is annoy to load and run for local files.
So...How?
> nix-shell --packages ruby_3_3.gems.rugged --command zsh
> gem install licensee
...
WARNING: You don't have /home/kachick/.local/share/gem/ruby/3.3.0/bin in your PATH,
gem executables (licensee) will not run.
> /home/kachick/.local/share/gem/ruby/3.3.0/bin/licensee version
9.18.0
Do not giveup for against the PATH missing warning, binary is there. You can use with absolute path
Nix is not a perfect solution if I want to use ruby-head or use latest stable which is not yet merged in nixpkgs.
Using a container may cover the use-case.
https://github.com/ruby/docker-images/pkgs/container/ruby is a solution.
> z ruby-ulid
> podman run --volume "$PWD:/$(basename "$PWD")" --workdir "/$(basename "$PWD")" -it ghcr.io/ruby/ruby:master-dev-jammy
> root@adb257ca732b:/ruby-ulid# ruby -v
ruby 3.5.0dev (2024-12-25T11:10:18Z master 69bb296fa6) +PRISM [x86_64-linux]
Setting an alias with -i
is much useful for behavior testing
> alias ruby_3_4='podman run -i ghcr.io/ruby/ruby:3.4.1-jammy ruby'
> ruby -e 'puts "foo\nbar\nbaz"' | ruby_3_4 -e 'STDIN.grep(/ba/) { puts it }'
bar
baz
It has time lag for latest releases. And required to run workflow dispatch for triggering the bot.
So I note here how to create the diff in local.
nix-shell \
-I nixpkgs='https://github.com/NixOS/nixpkgs/archive/6c90912761c43e22b6fb000025ab96dd31c971ff.tar.gz' \
--packages ruby_3_3 nodejs_20 nodejs_20.pkgs.yarn \
--command 'ruby new-versions.rb "ruby-3.4.0,ruby-3.4.1"; ./pre-commit; ruby generate-windows-versions.rb'
Ruby has strong regex engine and fluent syntax. So useful for filter commands.
However I can't remember the options in this 10+ years. So noted here
ruby -i -pe '$_.sub!(/^(history: .+v)\d+\.\d+\.\d+/) { "#{Regexp.last_match[1]}9.9.9" }' path