How to set up a new (development) instance of Codidact/QPixel Question
The QPixel repository on GitHub contains the source code for the Codidact software.
How can I set up a new development instance of it, so that I can work on it on my local machine?
Before you can get started, you need to check, whether you have all the prerequisites. QPixel is built with Ruby on Rail …
1y ago
Installing QPixel on Fedora Linux using RVM without brew If you happen to be installing in this situation, a few things …
5mo ago
Debian-based (including on WSL) Required time: less than 1 hour. This workflow was tested on : - Debian 12 (fres …
1y ago
I am adding some more information on prerequisites. For Arch-Based Linux : ```bash sudo pacman -Syyu sudo pacman …
3y ago
4 answers
I am adding some more information on prerequisites.
For Arch-Based Linux :
sudo pacman -Syyu
sudo pacman -Sy gcc
sudo pacman -Sy make
sudo pacman -Sy ruby autoconf bison base-devel ruby unixodbc
sudo pacman -Sy openssl
sudo snap install mysql --beta Or, sudo pacman -S mysql
For Windows :
You have to follow following method to get started.
- Install RubyInstaller.
-
You have run the following commands in command prompt(I forgot the name, simply called
cmd
)gem install rails
and,gem install bundler
- Download and install mysql.
0 comment threads
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
NoahTheDuke | (no comment) | Nov 15, 2021 at 03:08 |
zetyty | (no comment) | Jul 23, 2023 at 20:32 |
Before you can get started, you need to check, whether you have all the prerequisites. QPixel is built with Ruby on Rails, therefore you'll need:
- a Linux or Mac computer (Windows WSL is also okay, but slower; running Ruby on Windows is ultra-slow)
- Ruby installed (we recommend RVM or rbenv)
Prerequisites
If you have all of that, we can continue with installing the necessary packages. For Linux, run these commands:
sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install libmysqlclient-dev libmagickwand-dev
sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
sudo apt install mysql-server
For Mac, run:
xcode-select --install
brew install mysql bison openssl mysql-client
bundle config --global build.mysql2 --with-opt-dir="$(brew --prefix openssl)"
Next, you need to install the following helper applications:
Installing QPixel
Once you have completed installing the prerequisites, you can download QPixel:
git clone https://github.com/codidact/qpixel
cd qpixel
After downloading QPixel, you need to install all the dependencies. For that, you need to run
bundle install
If Ruby complains, that the Bundler hasn't been installed yet, use gem install bundler
and then re-run the above command.
Setting up the Database
If the database is not already running, start it. On MacOS you can do:
brew services start mysql
Before we can create, set up and seed the database, we need to make sure that we have a MySQL user. Sign into the MySQL console (sudo mysql -u root
for the default installation) and execute the following commands (replace the dummy credentials with secure ones):
CREATE USER qpixel@localhost IDENTIFIED BY 'choose_a_password_here';
GRANT ALL ON qpixel_dev.* TO qpixel@localhost;
GRANT ALL ON qpixel_test.* TO qpixel@localhost;
GRANT ALL ON qpixel.* TO qpixel@localhost;
Then you'll have to tell QPixel which credentials to use. Copy the config/database.sample.yml
to config/database.yml
and fill in the correct host, username and password. You'll also need to copy the Active Storage configuration from config/storage.sample.yml
to config/storage.yml
. Also, you will need to set the Redis connection details there too. Assuming that you always chose the default installation options, you'll only need to make changes to the username and the password from the sample file.
Now we want to create the database and the tables. Run:
rails db:create
rails db:schema:load
rails r db/scripts/create_tags_path_view.rb
rails db:migrate
Before we can continue and seed the data, you'll have to create the record for your (first) community. Open the Rails console with rails c
and run these two commands:
Community.create(name: 'Dev Community', host: 'localhost:3000')
Rails.cache.clear
After that you can call rails db:seed
to fill the database with necessary seed data, such as settings, help posts and default templates.
Now comes the big moment: You can start the QPixel server for the first time. Run:
rails s
Open a web browser and visit your server, which should be running under http://localhost:3000.
Creating an administrator account
On the dev server, create a new account through the "Sign up" route. Then switch back to the console to confirm your account (as sending mails shouldn't have been configured yet) and to promote your account to an administrator one. Open the rails console again and run:
User.last.update(confirmed_at: DateTime.now, is_global_admin: true)
If you prefer confirming accounts from the web, you can visit http://localhost:3000/letter_opener to access the confirmation email and then promote your user to admin with rails r "User.last.update(is_global_admin: true)"
.
Reload the web browser and you should see the elevated access.
New site setup
There's one more thing before your development server is fully up and running: the new site setup.
While being logged into your administrator account, go to http://localhost:3000/admin/setup. Review the settings (if you want; you can change them later) and click "Save and continue" to complete setting up the dev server.
✨ Your dev server is now ready.
The following users marked this post as Works for me:
User | Comment | Date |
---|---|---|
zetyty |
Thread: Works for me Works for me with Fedora 38! |
Jul 23, 2023 at 20:30 |
Installing QPixel on Fedora Linux using RVM without brew
If you happen to be installing in this situation, a few things might have different names. Here are some of the differences I had to allow for.
Disclaimer: I have no insight or familiarity with QPixel or any of the packages described below. These are just the variations that got me to a QPixel installation that was working well enough to display the Codidact homepage.
This may or may not be similar for Red Hat and CentOS installations.
ImageMagick
An error occurred while installing rmagick (4.2.6), and Bundler cannot continue.
Instead of the recommended libmagickwand-dev
, which is not available on Fedora, you can use ImageMagick-devel
:
dnf install ImageMagick-devel
I couldn't find an official guide to this but I stumbled upon the alternative name for the package in a guide to Python bindings for ImageMagick. That guide refers to yum
instead of dnf
as it's aimed at Red Hat, but it installed for me on Fedora using dnf
.
MySQL
An error occurred while installing mysql2 (0.5.4), and Bundler cannot continue.
Instead of the recommended mysql-server
, which is not available on Fedora, you can use the community maintained community-mysql-server
:
dnf install community-mysql-server
systemctl enable mysqld
systemctl start mysqld
I found I also needed to install mysql-devel
:
dnf install mysql-devel
The guide to installing MySQL on Fedora also includes instructions for installing Oracle's package instead of the community maintained one if you prefer.
libvips
libvips
is not available under that name on Fedora, instead it is called vips
:
dnf install vips
Redis
I discovered on the Redis Fedora page that redis-server
is not available under that name on Fedora, instead it is called redis
:
dnf install redis
systemctl enable redis
systemctl start redis
Integrating RVM with Gnome terminal
If you are using Gnome (the default desktop environment for Fedora), then the terminal is by default set up in a way that will give you the following error:
RVM is not a function
This is likely to be part of a larger error message depending on what you were trying to do. In particular, this prevents selecting a Ruby version using rvm use 3.3.0
.
You can find guidance and explanation on RVM's dedicated gnome terminal page (the solution is simply ticking a checkbox in the terminal preferences).
Security
This is not a security guide. Please use your own judgement on whether each command does or does not need to be entered with something like sudo
or su
. I am not qualified to tell you what is safe for your particular system.
Debian-based (including on WSL)
Required time: less than 1 hour.
This workflow was tested on :
- Debian 12 (fresh install with debian-12.0.0-amd64-netinst.iso on Virtual Box 7.0.8 and Windows 11 22H2 host)
- Debian 11 on WSL2 (Windows Subsystem Linux Version 2)[1] (on Windows 11 22H2 host).
- Ubuntu 22.04.2 LTS on WSL2 (on Windows 11 22H2 host).
1. Prerequisites
sudo apt update
sudo apt install gcc
sudo apt install make
sudo apt install default-libmysqlclient-dev # libmysqlclient-dev not disponible on Debian
sudo apt install libmagickwand-dev
sudo apt install autoconf bison build-essential libssl-dev libyaml-dev libreadline-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm-dev
sudo apt install curl
sudo apt install nodejs
sudo apt install redis
sudo apt install imagemagick
sudo apt install git
1.1. Database server
MySQL is not available on the Debian default distribution, thus MariaDB can be installed instead[2]:
sudo apt install mariadb-server
1.2. Ruby install
Example with rvm:
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
curl -sSL https://get.rvm.io | bash -s stable
If rvm installation is complete it will tells you which command to run in order to be able to use the rvm
command. In the installation outputs sample below, this command is (you need to run this command in each new openend terminal):
source /home/zetyty/.rvm/scripts/rvm
Installation outputs sample on Debian 12 (for user "zetyty"):
~$ curl -sSL https://get.rvm.io | bash -s stable
Downloading https://github.com/rvm/rvm/archive/1.29.12.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.12/1.29.12.tar.gz.asc
gpg: Signature made Fri 15 Jan 2021 07:46:22 PM CET
gpg: using RSA key 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
gpg: Good signature from "Piotr Kuczynski <[email protected]>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 7D2B AF1C F37B 13E2 069D 6956 105B D0E7 3949 9BDB
GPG verified '/home/zetyty/.rvm/archives/rvm-1.29.12.tgz'
Installing RVM to /home/zetyty/.rvm/
Adding rvm PATH line to /home/zetyty/.profile /home/zetyty/.mkshrc /home/zetyty/.bashrc /home/zetyty/.zshrc.
Adding rvm loading line to /home/zetyty/.profile /home/zetyty/.bash_profile /home/zetyty/.zlogin.
Installation of RVM in /home/zetyty/.rvm/ is almost complete:
* To start using RVM you need to run `source /home/zetyty/.rvm/scripts/rvm`
in all your open shell windows, in rare cases you need to reopen all shell windows.
Thanks for installing RVM 🙏
Please consider donating to our open collective to help us maintain RVM.
👉 Donate: https://opencollective.com/rvm/donate
Then, install ruby:
rvm install 3.1.2
2. QPixel
Download and install QPixel:
git clone https://github.com/codidact/qpixel
cd qpixel
bundle install
bundle install
outputs sample on Debian 12 (QPixel install in /home
directory):
bundle install
outputs sample on Debian 12 (QPixel install in /home
directory):~/qpixel$ bundle install
Bundler 2.3.7 is running, but your lockfile was generated with 2.4.13. Installing Bundler 2.4.13 and restarting using that version.
Fetching gem metadata from https://rubygems.org/.
Fetching bundler 2.4.13
Installing bundler 2.4.13
Fetching gem metadata from https://rubygems.org/.........
Using rake 13.0.6
Fetching concurrent-ruby 1.1.10
Installing concurrent-ruby 1.1.10
Fetching i18n 1.12.0
Installing i18n 1.12.0
Fetching minitest 5.16.3
Installing minitest 5.16.3
Fetching tzinfo 2.0.5
Installing tzinfo 2.0.5
Fetching activesupport 7.0.4
Installing activesupport 7.0.4
Fetching builder 3.2.4
Installing builder 3.2.4
Fetching erubi 1.11.0
Installing erubi 1.11.0
Fetching racc 1.6.2
Installing racc 1.6.2 with native extensions
Fetching nokogiri 1.14.3 (x86_64-linux)
Installing nokogiri 1.14.3 (x86_64-linux)
Fetching rails-dom-testing 2.0.3
Installing rails-dom-testing 2.0.3
Fetching crass 1.0.6
Installing crass 1.0.6
Fetching loofah 2.19.1
Installing loofah 2.19.1
Fetching rails-html-sanitizer 1.4.4
Installing rails-html-sanitizer 1.4.4
Fetching actionview 7.0.4
Installing actionview 7.0.4
Fetching rack 2.2.6.4
Installing rack 2.2.6.4
Fetching rack-test 2.0.2
Installing rack-test 2.0.2
Fetching actionpack 7.0.4
Installing actionpack 7.0.4
Fetching nio4r 2.5.8
Installing nio4r 2.5.8 with native extensions
Fetching websocket-extensions 0.1.5
Installing websocket-extensions 0.1.5
Fetching websocket-driver 0.7.5
Installing websocket-driver 0.7.5 with native extensions
Fetching actioncable 7.0.4
Installing actioncable 7.0.4
Fetching globalid 1.0.1
Installing globalid 1.0.1
Fetching activejob 7.0.4
Installing activejob 7.0.4
Fetching activemodel 7.0.4
Installing activemodel 7.0.4
Fetching activerecord 7.0.4
Installing activerecord 7.0.4
Fetching marcel 1.0.2
Installing marcel 1.0.2
Fetching mini_mime 1.1.2
Installing mini_mime 1.1.2
Fetching activestorage 7.0.4
Installing activestorage 7.0.4
Fetching mail 2.7.1
Installing mail 2.7.1
Using digest 3.1.0
Fetching timeout 0.3.0
Installing timeout 0.3.0
Fetching net-protocol 0.1.3
Installing net-protocol 0.1.3
Fetching strscan 3.0.4
Installing strscan 3.0.4 with native extensions
Using net-imap 0.2.3
Using net-pop 0.1.1
Using net-smtp 0.3.1
Fetching actionmailbox 7.0.4
Installing actionmailbox 7.0.4
Fetching actionmailer 7.0.4
Installing actionmailer 7.0.4
Fetching actiontext 7.0.4
Installing actiontext 7.0.4
Fetching public_suffix 5.0.0
Installing public_suffix 5.0.0
Fetching addressable 2.8.1
Installing addressable 2.8.1
Fetching ast 2.4.2
Installing ast 2.4.2
Fetching awesome_print 1.9.2
Installing awesome_print 1.9.2
Fetching aws-eventstream 1.2.0
Installing aws-eventstream 1.2.0
Fetching aws-partitions 1.628.0
Installing aws-partitions 1.628.0
Fetching aws-sigv4 1.5.1
Installing aws-sigv4 1.5.1
Fetching jmespath 1.6.1
Installing jmespath 1.6.1
Fetching aws-sdk-core 3.145.0
Installing aws-sdk-core 3.145.0
Fetching aws-sdk-kms 1.58.0
Installing aws-sdk-kms 1.58.0
Fetching aws-sdk-s3 1.114.0
Installing aws-sdk-s3 1.114.0
Fetching mime-types-data 3.2022.0105
Installing mime-types-data 3.2022.0105
Fetching mime-types 3.4.1
Installing mime-types 3.4.1
Using rexml 3.2.5
Fetching xml-simple 1.1.9
Installing xml-simple 1.1.9
Fetching aws-ses-v4 0.8.1
Installing aws-ses-v4 0.8.1
Fetching bcrypt 3.1.18
Installing bcrypt 3.1.18 with native extensions
Fetching bindex 0.8.1
Installing bindex 0.8.1 with native extensions
Using bundler 2.4.13
Fetching byebug 11.1.3
Installing byebug 11.1.3 with native extensions
Using matrix 0.4.2
Fetching regexp_parser 2.5.0
Installing regexp_parser 2.5.0
Fetching xpath 3.2.0
Installing xpath 3.2.0
Fetching capybara 3.38.0
Installing capybara 3.38.0
Fetching chartkick 4.2.1
Installing chartkick 4.2.1
Fetching chronic 0.10.2
Installing chronic 0.10.2
Fetching chunky_png 1.4.0
Installing chunky_png 1.4.0
Fetching coffee-script-source 1.12.2
Installing coffee-script-source 1.12.2
Fetching execjs 2.8.1
Installing execjs 2.8.1
Fetching coffee-script 2.4.1
Installing coffee-script 2.4.1
Fetching method_source 1.0.0
Installing method_source 1.0.0
Fetching thor 1.2.1
Installing thor 1.2.1
Fetching zeitwerk 2.6.0
Installing zeitwerk 2.6.0
Fetching railties 7.0.4
Installing railties 7.0.4
Fetching coffee-rails 5.0.0
Installing coffee-rails 5.0.0
Fetching commonmarker 0.23.9
Installing commonmarker 0.23.9 with native extensions
Fetching counter_culture 3.2.1
Installing counter_culture 3.2.1
Fetching json 2.6.2
Installing json 2.6.2 with native extensions
Fetching docile 1.4.0
Installing docile 1.4.0
Fetching simplecov-html 0.10.2
Installing simplecov-html 0.10.2
Fetching simplecov 0.16.1
Installing simplecov 0.16.1
Fetching sync 0.5.0
Installing sync 0.5.0
Fetching tins 1.31.1
Installing tins 1.31.1
Fetching term-ansicolor 1.7.1
Installing term-ansicolor 1.7.1
Fetching coveralls 0.8.23
Installing coveralls 0.8.23
Fetching css_parser 1.11.0
Installing css_parser 1.11.0
Fetching orm_adapter 0.5.0
Installing orm_adapter 0.5.0
Fetching responders 3.0.1
Installing responders 3.0.1
Fetching warden 1.2.9
Installing warden 1.2.9
Fetching devise 4.8.1
Installing devise 4.8.1
Fetching ruby-saml 1.14.0
Installing ruby-saml 1.14.0
Fetching devise_saml_authenticatable 1.9.0
Installing devise_saml_authenticatable 1.9.0
Fetching diffy 3.4.2
Installing diffy 3.4.2
Fetching e2mmap 0.1.0
Installing e2mmap 0.1.0
Fetching fastimage 2.2.6
Installing fastimage 2.2.6
Fetching ffi 1.15.5
Installing ffi 1.15.5 with native extensions
Fetching flamegraph 0.9.5
Installing flamegraph 0.9.5
Fetching groupdate 6.1.0
Installing groupdate 6.1.0
Fetching hashie 5.0.0
Installing hashie 5.0.0
Fetching htmlentities 4.3.4
Installing htmlentities 4.3.4
Fetching mini_magick 4.11.0
Installing mini_magick 4.11.0
Fetching ruby-vips 2.1.4
Installing ruby-vips 2.1.4
Fetching image_processing 1.12.2
Installing image_processing 1.12.2
Fetching jbuilder 2.11.5
Installing jbuilder 2.11.5
Fetching jquery-rails 4.5.0
Installing jquery-rails 4.5.0
Fetching launchy 2.5.0
Installing launchy 2.5.0
Fetching letter_opener 1.8.1
Installing letter_opener 1.8.1
Fetching letter_opener_web 2.0.0
Installing letter_opener_web 2.0.0
Fetching rb-fsevent 0.11.2
Installing rb-fsevent 0.11.2
Fetching rb-inotify 0.10.1
Installing rb-inotify 0.10.1
Fetching listen 3.7.1
Installing listen 3.7.1
Fetching memory_profiler 1.0.0
Installing memory_profiler 1.0.0
Fetching minitest-ci 3.4.0
Installing minitest-ci 3.4.0
Fetching mysql2 0.5.4
Installing mysql2 0.5.4 with native extensions
Fetching rack-protection 2.2.2
Installing rack-protection 2.2.2
Fetching omniauth 2.1.0
Installing omniauth 2.1.0
Fetching parallel 1.22.1
Installing parallel 1.22.1
Fetching parser 3.1.2.1
Installing parser 3.1.2.1
Fetching pkg-config 1.5.1
Installing pkg-config 1.5.1
Fetching premailer 1.16.0
Installing premailer 1.16.0
Fetching premailer-rails 1.11.1
Installing premailer-rails 1.11.1
Fetching puma 5.6.5
Installing puma 5.6.5 with native extensions
Fetching rack-mini-profiler 3.0.0
Installing rack-mini-profiler 3.0.0
Fetching rails 7.0.4
Installing rails 7.0.4
Fetching rails-controller-testing 1.0.5
Installing rails-controller-testing 1.0.5
Fetching rainbow 3.1.1
Installing rainbow 3.1.1
Fetching redis 4.8.0
Installing redis 4.8.0
Fetching reverse_markdown 2.1.1
Installing reverse_markdown 2.1.1
Fetching rmagick 5.2.0
Installing rmagick 5.2.0 with native extensions
Fetching rotp 6.2.0
Installing rotp 6.2.0
Fetching rqrcode_core 1.2.0
Installing rqrcode_core 1.2.0
Fetching rqrcode 2.1.2
Installing rqrcode 2.1.2
Fetching rubocop-ast 1.21.0
Installing rubocop-ast 1.21.0
Fetching ruby-progressbar 1.11.0
Installing ruby-progressbar 1.11.0
Fetching unicode-display_width 2.2.0
Installing unicode-display_width 2.2.0
Fetching rubocop 1.36.0
Installing rubocop 1.36.0
Fetching rubocop-rails 2.16.0
Installing rubocop-rails 2.16.0
Fetching rubyzip 2.3.2
Installing rubyzip 2.3.2
Fetching sassc 2.4.0
Installing sassc 2.4.0 with native extensions
Fetching sprockets 4.1.1
Installing sprockets 4.1.1
Fetching sprockets-rails 3.4.2
Installing sprockets-rails 3.4.2
Fetching tilt 2.0.11
Installing tilt 2.0.11
Fetching sassc-rails 2.1.2
Installing sassc-rails 2.1.2
Fetching sass-rails 6.0.0
Installing sass-rails 6.0.0
Fetching websocket 1.2.9
Installing websocket 1.2.9
Fetching selenium-webdriver 4.7.1
Installing selenium-webdriver 4.7.1
Fetching spring 4.0.0
Installing spring 4.0.0
Fetching stackprof 0.2.21
Installing stackprof 0.2.21 with native extensions
Fetching stripe 5.55.0
Installing stripe 5.55.0
Fetching terser 1.1.12
Installing terser 1.1.12
Fetching thwait 0.2.0
Installing thwait 0.2.0
Fetching tzinfo-data 1.2022.3
Installing tzinfo-data 1.2022.3
Fetching web-console 4.2.0
Installing web-console 4.2.0
Fetching webdrivers 5.2.0
Installing webdrivers 5.2.0
Fetching whenever 1.0.0
Installing whenever 1.0.0
Fetching will_paginate 3.3.1
Installing will_paginate 3.3.1
Fetching will_paginate-bootstrap 1.0.2
Installing will_paginate-bootstrap 1.0.2
Bundle complete! 58 Gemfile dependencies, 157 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
If the bundle install failed because of some kind of "PermissionError", you may have several ruby installs on your system and then you can take a look at this post.
3. Start MariaDB and redis servers
Run:
sudo systemctl start mariadb
On WSL we can't use systemctl
but service
instead (see this answer), it is also necessary to stop the execution of a MySQL/MariaDB server on the Windows Host and on other running WSL (because this prevents the server from being launched on the current WSL)[3]:
sudo service mariadb start
And don't forgot redis:
sudo service redis-server start
4. Final steps
At this point, you can follow the workflow described in this answer (starting with new database user creation and generation of config/database.yml
and config/storage.yml
).
But, with MariaDB, "you will need to replace all occurrences of utf8mb4_0900_ai_ci
with utf8mb4_unicode_ci
in db/schema.rb
" (4 occurrences) [cited from the GitHub installation Guide].
NB: if you stop your system before the rails s
"big moment", be sure you have redis-server
running (you can do sudo service redis-server restart
). Same comment for mariadb-server
.
-
I was not able to run QPixel on Debian WSL1 because I was not able to run the rails console (but I got no problem with WSL2). Also the install is significantly faster with WSL2. ↩︎
-
If you really want to install MySQL, you can take a look at this discussion, this answer regarding Dockerized instance of MySQL on WSL or directly on the Windows Host and this official workflow). ↩︎
-
To stop MySQL on Windows: Open a on command prompt and run
net stop MySQL80
. On other running WSL, (i) you can stop MySQL/MariaDB server on other WSL or (ii) stop some running WSL by opening a PowerShell and runwsl -t DISTRO-NAME
- you can find the list of allDISTRO-NAME
installed and their status (running/stopped) withwsl -l -v
. ↩︎
1 comment thread