How to get a historic version of Canvas up and running. Other than a few specific points, these tips may be useful for other Rails apps.
- provision a linux VM (see MACOS_NOTE at the end of this document)
- if you are using Multipass, be sure to set up adequate disk space (e.g.
multipass launch --disk 30G
), since the 5GB default will not be sufficient and there is no way to increase it after the fact. don't ask me how I know this. also use--mem 8G
or thereabouts because the 1GB default is also not enough (you can change this after the fact, but it involves editing a json file buried in a directory you need sudo to get into)
- if you are using Multipass, be sure to set up adequate disk space (e.g.
- pull down the repo
- set up rvm and chruby
- you can browse with e.g.
git log --before 2012-02-23
- then get it with
git checkout
- the older you get, the lesser the chance that the code is actually runnable at some arbitrary timestamp. you may have better luck checking out specific tags.
- look at
Gemfile.d/_before.rb
(or justGemfile
in very old versions) - note that IME bundler older than 1.8.x will not talk to rubygems anymore but I had success with that version
- if you are using Rails older than 3, use Ruby 1.8.7. you will not need a ruby version older than this
- if you're lucky, something like
ruby-install 2.4.10
will work even if the version is past EOL - you will not be that lucky
- openssl incompatibility is the primary reason why; old ruby versions need 1.0, and your linux distro probably uses a newer version, with a different API
- you will likely need to download openssl 1.0 and compile it from source
make install
puts it in/usr/local/ssl
which, on ubuntu at least, does not clash with the built-in library- when compiling ruby, point at the SSL 1.0 library, e.g.
CFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib" ruby-install 2.4.10
- with really old ruby versions, I had better luck with ruby-build than ruby-install. this is part of the rbenv project, but the installation will work with chruby if you provide the location chruby looks for rubies. build with e.g.
CFLAGS="-I/usr/local/ssl/include" LDFLAGS="-L/usr/local/ssl/lib" ruby-build 1.8.7-p374 ~/.rubies/ruby-1.8.7-p374
- if the compile fails, it may be because of signature mismatches with openssl or zlib. I saw both in my time travels. for example, ruby's zlib extension tried to put the return value from
get_crc_table
into anunsigned long *
, which is the wrong type (and probably changed from 32 bits to 64 bits at some point). changing it to the correct type,z_crc_t *
, fixed this issue. - if you're using ruby-build, the ruby repo is in
/tmp
; if you're using ruby-install, it's in~/src
. after fixing the build issues, you can runmake
andmake install
to complete the process
- select the proper ruby version with chruby
- install bundler with e.g.
gem install bundler -v 1.8.9
- if it hangs when trying to talk to rubygems, try a newer version than the contemporary canvas actually used (IME anything older than 1.8 will not work)
- try
--without sqlite
to make life a little simpler - you will see two kinds of errors:
- gems where a version wasn't specified, and bundler tried to get the newest one, which is incompatible with your version of ruby
- go to rubygems.org and find a contemporary version, then update the Gemfile to use that version (or add it if it's not in there already; it's likely another gem botched the dependency)
- gems where the native extension fails to build
- you may need to find a newer version of the gem that's compatible with whatever OS change broke the old one... but hopefully not new enough that it's incompatible with your version of ruby or canvas
- if all else fails, verify the gem is actually needed. if it's a test dependency you can just comment it out (unless you really want to run ancient specs)
- gems where a version wasn't specified, and bundler tried to get the newest one, which is incompatible with your version of ruby
- if your version of canvas has a
.nvmrc
, great, use that version - if it doesn't, you can look for a contemporary version of node; however, IME anything older than 0.10 won't talk to modern services due to old-SSL deprecation
- if a too-new package is selected implicity, you can install a contemporary one with e.g.
npm install [email protected]
and try again (adding it to the package.json may not help because npm is happy to install multiple versions of the same package and may (fail to) get the newer dependency before finding your version)
bundle exec rake canvas:compile_assets
- you may need to install libsass
- if production assets fail to build, meh, you don't need 'em
- you can probably get away with using the
.yml.example
files for the most part - note that very old canvas versions can use sqlite; look for
database.yml.sqlite-example
bundle exec rake db:initial_setup
- I successfully got 2015 canvas talking to postgres 14.2 but this did require a few simple tweaks to fix errors that cropped up during rails boot/db migration. still probably easier than installing legacy postgres
- remove the
-i
frompg_dump
- change
pg_current_xlog_location
topg_current_wal_lsn
- change
pg_last_xlog_replay_location
topg_last_wal_replay_lsn
- remove the
bundle exec rails server
works if rails is 3 or newer- for really old canvas, use
script/server
- changes in clang break the build for some old C code (either ruby itself or gem/npm native extensions). mostly it seems like clang deciding to promote the "no implicit function declaration" warning to an error by default causes a lot of problems. to build ruby:
to build gems:CFLAGS="-Wno-implicit-function-declaration -I$(brew --prefix [email protected])/include" LDFLAGS="-L$(brew --prefix [email protected])/lib" ruby-build 1.8.7-p375 ~/.rubies/ruby-1.8.7
gem install ffi -v '1.9.14' -- --with-cflags=-Wno-implicit-function-declaration
- older versions of node can't find the Xcode command-line development tools. newer versions may be incompatible with your modules. this is why I ended up switching to Linux. there may be workarounds at https://github.com/nodejs/node-gyp/blob/master/macOS_Catalina.md but I couldn't get anything short of reinstalling Xcode to work, and I was unwilling to go that far.