dbt-labs/hub.getdbt.com

Instructions in `CONTRIBUTING.md` are not working for MacOS >= 12.3

b-per opened this issue · 12 comments

b-per commented

I am following the instructions to run the Hub locally but bundle install is failing and the troubleshooting comments don't work either.

I get this error with libv8

    current directory: /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/ext/libv8
/Users/bper/.rbenv/versions/2.7.2/bin/ruby -I /Users/bper/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20220810-84506-ypu5nl.rb extconf.rb
creating Makefile
/Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/ext/libv8/builder.rb:86:in `setup_python!': libv8 requires python 2 to be installed in order to build,
but it is currently 3.9.12 (RuntimeError)
        from /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/ext/libv8/builder.rb:53:in `build_libv8!'
        from /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:24:in `install!'
        from extconf.rb:7:in `<main>'

extconf failed, exit code 1

Gem files will remain installed in /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19 for inspection.
Results logged to /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/extensions/arm64-darwin-21/2.7.0/libv8-3.16.14.19/gem_make.out

This seems to be related to the fact that Python 2 has been removed from MacOS since 12.3 and I am on 12.4

b-per commented

I installed Python 2 and tried but got other errors.

I then tried the following to install v8, which worked:

env \                                                                       
  CXX=clang++ \
  GYPFLAGS=-Dmac_deployment_target=12.4 \
gem install libv8 --version 3.16.14.19 -- --with-system-v8

But then installing rubyracer still fails, even when trying with

gem install therubyracer -- --with-v8-dir=/opt/homebrew/Cellar/v8/10.2.154.4

Error:

Building native extensions with: '--with-v8-dir=/opt/homebrew/Cellar/v8/10.2.154.4'
This could take a while...
ERROR:  Error installing therubyracer:
        ERROR: Failed to build gem native extension.

    current directory: /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/therubyracer-0.12.3/ext/v8
/Users/bper/.rbenv/versions/2.7.2/bin/ruby -I /Users/bper/.rbenv/versions/2.7.2/lib/ruby/2.7.0 -r ./siteconf20220810-7111-1eyxawh.rb extconf.rb --with-v8-dir\=/opt/homebrew/Cellar/v8
checking for -lpthread... yes
checking for -lobjc... yes
checking for v8.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
...
/Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/ext/libv8/location.rb:50:in `configure': By using --with-system-v8, you have chosen to use the version  (Libv8::Location::System::NotFoundError)
of V8 found on your system and *not* the one that is bundled with 
the libv8 rubygem. 

However, your system version of v8 could not be located. 

Please make sure your system version of v8 that is compatible 
with 3.16.14.19 installed. You may need to use the 
--with-v8-dir option if it is installed in a non-standard location
        from /Users/bper/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/libv8-3.16.14.19/lib/libv8.rb:7:in `configure_makefile'
        from extconf.rb:32:in `<main>'

This issue on the rubyracer repo mentions that getting it installed on M1 is challenging and suggest changing library (which I guess is not a small update)

@b-per Thank you for opening and describing your experience in excellent detail!

I ran into issues myself when doing this install -- it's a royal pain 🤕

My thought for rising above the fray is to create a Dockerfile within this repo that will allow contributors to bypass this headache (hopefully! 🤞).

If you or anyone else does find some instructions that work for MacOS >= 12.3, please share them or open a PR!

b-per commented

Do you have any instruction/code you could share on how the code of this repo is used/deployed? I tried creating a Docker image and also add other issues with libv8/therubyracer. If we have a set of steps used today for the website I could try to replicate those in Docker.

@b-per thank you for giving Docker a shot!

The instructions for launching a local instance of the website at are here. Namely,

git submodule update --init
bundle install
bundle exec middleman serve --port 4567

If all goes well, you'll be able to see your development version of the website at http://localhost:4567/

Then you can actually use it for dbt deps with these instructions.

b-per commented

Thanks Doug. I guess my question was more about what OS, Linux distribution etc... is running those commands on our server. It might help me pick up a correct base Docker image. I tried with a Debian Bullseye and it didn't work hence why I am asking.

High level

Regardless of the operating system, a local environment just needs to run middleman (I think?).

This is one Gist for running middleman based off a Ruby image that was my first hit for "middleman ruby docker". I didn't try it out though.

Low level

hub.getdbt.com is running on Netlify, but I don't know which OS is being used.

After some Googling, maybe it's using Ubuntu 20.04 Focal Fossa ?

Here's their build image: https://hub.docker.com/r/netlify/build

This could be something to look into: https://github.com/netlify/cli/blob/main/docs/netlify-dev.md

b-per commented

I spent a fair bit of time trying to get it working on Docker but when it worked I realized that it requires pulling from the submodule (which didn't work from Docker).

But, following your advice on middleman, I got it working on my M1 with the following Gemfile:

source 'https://rubygems.org'


gem 'middleman'
gem 'middleman-autoprefixer'
gem 'middleman-livereload'
gem 'tzinfo-data', platforms: [:mswin, :mingw, :jruby]
gem 'wdm', '~> 0.1', platforms: [:mswin, :mingw]
gem 'redcarpet', '3.5.1'
gem 'pry'
gem 'rack', '~> 2.2.3.1'

I removed some lines and deleted the pinned versions for middleman. I believe that it requires having NodeJS installed (to replace therubyracer), but I didn't have any problem as I already had it installed.

@b-per do you still have the Dockerfile that worked for you?

Now that the submodule was removed in #1782, maybe we can publish a Dockerfile that can allow for running this repo locally (regardless of platform)?

b-per commented

I ended by running it natively on my M1 and not using Docker 😄 so I don't have any Dockerfile as of now. I could work on getting one though.

Working on getting a Dockerfile would be awesome if you are willing!

That way others can hopefully avoid the pain you went through.

I added some commentary on how to lock and test Gemfile changes here.

b-per commented

I created a PR with a Dockerfile and short instructions: #1794

Considering this resolved by #1794 and #1802.

Can revisit local instructions that are operating system specific if an impactful enough need arises.