Permission denied during Ubuntu developer setup

I get the following when I run this command:

“rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - tmp
/home/folder/discourse/config/boot.rb:23:in `<top (required)>'
/home/folder/discourse/config/application.rb:16:in `require'
/home/folder/discourse/config/application.rb:16:in `<top (required)>'
/home/folder/discourse/Rakefile:7:in `require'
/home/folder/discourse/Rakefile:7:in `<top (required)>'
/home/folder/.rbenv/versions/2.6.2/bin/bundle:23:in `load'
/home/folder/.rbenv/versions/2.6.2/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)”

Any suggestions on where I have gone wrong and how to get past this?

It looks like you didn’t create the database or somehow didn’t get the permissions right.

Followed every step !!!
Going to start from scratch!!

I was hit by the same. The installer actually expects the developer user to have UID 1000.

If your regular user does not have UID 1000 (id -u should return 1000), then you can create a special user for your Discourse development:

# groupadd -g 1000 discourse
# useradd -m -g 1000 -u 1000 -s /bin/bash discourse

I was writing a more detailed setup because of this: see below

https://dev.cepheide.org/t/developer-setup-for-discourse/25 (link requires login)

1 Like

Let me give that a try!!!
Clicked on your link but its asking for a login LOL

Ah, sorry, here it is – it’s missing the plugins info, with docker, I missed that part… This is a wiki:

If you want to develop Discourse plugins, you need to setup a Discourse instance for development.

You can follow the developer setup guides:

One thing that’s missing from those guides is that the developer setup expects your UID to be 1000, otherwise you will get EACCESS errors.

1. Create a user for development

If your usual UID differs from 1000:

# groupadd -g 1000 discourse
# useradd -g 1000 -u 1000 -s /bin/bash -m discourse

We put the discourse user in the docker group so it can play with Docker, and in the sudoers group so it can gain root if needed.

We also want to use Ruby, so let’s install chruby and ruby-install:

# su - discourse
$ git clone https://github.com/postmodern/ruby-install
$ pushd ruby-install && sudo make install && popd
$ git clone https://github.com/postmodern/chruby
$ pushd chruby && sudo make install && popd

At the time of writing, Ruby is at version 2.6.3, let’s install it:

$ ruby-install ruby-2.6.3
...
$ echo 'source /usr/local/share/chruby/chruby.sh' >> ~/.bashrc
$ echo 'source /usr/local/share/chruby/auto.sh' >> ~/.bashrc
$ exec bash

2. Install Discourse

Now that we have a user with UID 1000 and Ruby installed, let’s move on to Discourse:

$ git clone https://github.com/discourse/discourse
$ cd discourse
$ echo '2.6.3' > .ruby-version
$ cd .
$ ruby --version
$ ./bin/docker/boot_dev --init

The installer will ask you for:

  • an admin email
  • an admin password (10 or more characters)
  • the admin username will be the username of your email

Now let’s start the development server:

$ ./bin/docker/unicorn

You’re ready to browse http://localhost:9292/

You can now stop the development server with:

$ ./bin/docker/shutdown_dev

3. Adding plugins

There’s a big caveat compared with non-Docker plugin development: you cannot use symlinks here!. So instead, you must either: 1) put your plugin repositories inside the ~/discourse/plugins directory, or 2) add a Docker volume for this directory (this won’t be covered here since early tests suggest difficulties).

Discourse will pick up plugins in its plugins directory. The easy way is to simply put your plugin development code there. So we can create a new plugin. There are several ways to do it, including a script (to be documented).
For now let’s do it by hand:

$ mkdir -p ~/discourse/plugins/sample-plugin
$ touch ~/discourse/plugins/sample-plugin/plugin.rb

Now you’re ready to follow the Beginner’s Guide to Discourse Plugin Development series.

4 Likes

I get this “groupadd: GID ‘1000’ already exists”

Did you run the id command?

  • id -u gives you your UID (“user ID”, it should be 1000 to run the installer to the end)
  • id -g givers you your GID (“group ID”)

Usually on Debian-based systems, like Ubuntu, the first user has UID:GID 1000:1000. So if that’s your case, maybe you missed something else, like creating a Postgres user for yourself (which should be automated as well on Ubuntu…).

sudo -u postgres createuser -s username
createuser: creation of new role failed: ERROR: role “username” already exists

Setup a new Ubuntu 18.04 Server
Run “bundle install” and now see this:

"Post-install message from certified:
IMPORTANT: Remember to use the included executable certifed-update regularly to keep your certificate bundle up to date.
Post-install message from discourse_image_optim:
Rails image assets optimization is extracted into image_optim_rails gem
You can safely remove config.assets.image_optim = false if you are not going to use that gem
Post-install message from rubocop:
Performance cops have been removed from RuboCop 0.68. Use the rubocop-performance gem instead.

Put this in your Gemfile.

gem 'rubocop-performance'

And then execute:

$ bundle install

Put this into your .rubocop.yml.

require: rubocop-performance
```"

And back to this sigh:

grep 1000 /etc/passwd

See what user that is. Install as that user.

If that doesn’t suit you, you’ll need to head over to Stack Exchange and see how to change the UID of whoever has 1000 and the account that you want to use.

1 Like

Thanks… I am going to do one more clean install, I only create one user on install so not sure whats causing this.

“ Installing Bundler …

Fetching bundler-2.0.2.gem

bundler’s executable “bundle” conflicts with /home/oberon/.rbenv/versions/2.6.2/bin/bundle

Overwrite the executable? [yN]”

Should the script not be changed to accommodate this?

You should be using Ruby 2.6.3. It should fix a number of bundler issues (Bundler 1.17.3, Rubygems 3.0.4). Try installing Ruby 2.6.3 then if the versions don’t match run gem update --system.

1 Like

Another caveat: if you run into:

$ bundle
Fetching source index from http://localhost:9292/

Try again with --full-index:

$ bundle --full-index

Bundler will use the right source.

I mention it here because I’ve seen many answers to this issue recommending changing the source from HTTPS to HTTP: of course this is very bad advice.

1 Like
grep 1000 /etc/passwd
discourse:x:1000:1000:discourse,,,:/home/discourse:/bin/bash

Step by step according to the Guide and still getting the same:

discourse@disctest:~/discourse$ bundle exec rake db:create db:migrate
rake aborted!
Errno::EACCES: Permission denied @ dir_s_mkdir - tmp
/home/discourse/discourse/config/boot.rb:23:in `<top (required)>'
/home/discourse/discourse/config/application.rb:16:in `require'
/home/discourse/discourse/config/application.rb:16:in `<top (required)>'
/home/discourse/discourse/Rakefile:7:in `require'
/home/discourse/discourse/Rakefile:7:in `<top (required)>'
/home/discourse/.rbenv/versions/2.6.2/bin/bundle:23:in `load'
/home/discourse/.rbenv/versions/2.6.2/bin/bundle:23:in `<main>'
(See full trace by running task with --trace)

Are you sure the ~/discourse directory is owned by the discourse user?

2 Likes

As it turns out the discourse user was not the owner of the directory
Thank you to everybody for their time and effort and apologies for the NOOB error.
I am now up and running and much happier!!!

3 Likes