Discourse Theme CLI (console app to help you build themes)


(Sarah) #34

Hey, I have added SSL to my discourse and now the CLI tool is giving me an SSL error.

    Uploading theme from <my_dir> to https://forums.mysite.com : /usr/lib/ruby/2.3.0/net/http.rb:933:in `connect_nonblock': SSL_connect returned=1 errno=0 state=error: certificate verify failed (OpenSSL::SSL::SSLError)
        from /usr/lib/ruby/2.3.0/net/http.rb:933:in `connect'
        from /usr/lib/ruby/2.3.0/net/http.rb:863:in `do_start'
        from /usr/lib/ruby/2.3.0/net/http.rb:852:in `start'
        from /usr/lib/ruby/2.3.0/net/http.rb:1398:in `request'
        from /var/lib/gems/2.3.0/gems/discourse_theme-0.1.6/lib/discourse_theme/uploader.rb:93:in `block in upload_full_theme'
        from /var/lib/gems/2.3.0/gems/discourse_theme-0.1.6/lib/discourse_theme/uploader.rb:87:in `open'
        from /var/lib/gems/2.3.0/gems/discourse_theme-0.1.6/lib/discourse_theme/uploader.rb:87:in `upload_full_theme'
        from /var/lib/gems/2.3.0/gems/discourse_theme-0.1.6/lib/discourse_theme/cli.rb:114:in `run'
        from /var/lib/gems/2.3.0/gems/discourse_theme-0.1.6/bin/discourse_theme:5:in `<top (required)>'
        from /usr/local/bin/discourse_theme:23:in `load'
        from /usr/local/bin/discourse_theme:23:in `<main>'

Previously, the discourse_theme CLI worked fine until I added SSL.
I am using the Ubuntu subsystem on Windows.

Any ideas?

(Sam Saffron) #35

Interesting, this is indicating SSL is probably not installed right in your Ruby. Can you let me know how you install Ruby (rvm, rbenv, ubuntu apt-get or by hand?)

(Sarah) #36

To install ruby I used:

   sudo apt-get install ruby
   sudo apt-get install ruby-dev
   sudo apt install ruby-bundler

I have tried to install rvm, but the install seems to fail because of permission issues (even with sudo it doesnt work). I also dont have rbenv installed.

ruby -v
ruby 2.3.1p112 (2016-04-26) [x86_64-linux-gnu]

gem -v


OpenSSL> version
OpenSSL 1.0.2g  1 Mar 2016

(Sam Saffron) #37

These commands may shed some light: SSL certificate verify failure · Issue #1758 · rubygems/rubygems · GitHub can you try running them? (except for the rvm stuff)

(Sarah) #38

I think the underlying issue is with certificates in ruby. Which, isn’t a problem with the discourse_theme CLI tool itself. But someone else might encounter this if they have a similar setup as myself.

From the article you linked, I tried
ruby -ropenssl -e 'puts OpenSSL::X509::DEFAULT_CERT_FILE'
My output was
Then I ran
ruby -ropenssl -e 'puts OpenSSL::OPENSSL_VERSION'

Since I don’t have brew installed, instead of brew install I did sudo apt upgrade openssl
the command did a bunch of stuff but the version is still the same OpenSSL 1.0.2g 1 Mar 2016 .

Then I managed to run the rvm command
rvm reinstall 2.2.2 --with-openssl-dir=/usr/lib/ssl/cert.pem

When I run the discourse_theme watch . I still get the same error as my first post.

Since this issue seems to be around certs, I also tried
apt-get install openssl ca-certificates

And also grabbed the .crt file used for Discourse’s SSL and converted it to a .pem. Then
export SSL_CERT_FILE=<Path to my .pem file>

Still no luck :frowning:

(Sam Saffron) #39

I really like how you are attacking this problem :clap:

My recommendation here would be to just take matters into your own hands here and shift to rbenv.

I think this guide is reasonable: How To Install Ruby on Rails with rbenv on Ubuntu 16.04 | DigitalOcean and worth a shot.

The advantage is that rvm’s ruby build takes care of a lot of the pesky ssl stuff correctly and also it will allow you to run ruby 2.4.4 which is what you really want.

In general I avoid packaged Ruby on my dev stuff.

(Sarah) #40

Hey Sam,

After successfully installing rbenv and following the instructions in the link you provided I’m still getting the same error (from my first post).

Looking at the output more closely, I wonder if the http method in uploader.rb might be the culprit?
This isn’t really my area of expertise, what are your thoughts?

(Sam Saffron) #41

There is another alternative here, perhaps something is up with your cert, what URL is your site at we can have a quick look to see if there is something up with it.

(Joe) #42


This is pretty minor and I realise that not all themes will have settings but…

would it be possible to add settings.yml to the list of files that are generated by discourse_theme new :grin:

As of now, I have to manually create the file if a theme has settings.


I would also love to see this added. Fortunately, it looks like there’s already a commit for it, so I imagine it will probably be in the next release :smiley:

(Sam Saffron) #44

0.1.7 is now released! :wink:

(Ryan Erwin) #45

I’ve made sure to use my User API Key but I’m still unable to connect via:

 % discourse_theme watch ~/Dev/Dark
Using https://www.EXAMPLE.com defined in /home/ryan/.discourse_theme
Using previously stored api key in /home/ryan/.discourse_theme
Uploading theme from /home/ryan/Dev/Dark to https://www.EXAMPLE.com : Error importing theme status: 403
{"errors":["You are not permitted to view the requested resource."],"error_type":"invalid_access"}

This is strange, because my API Key is connect to my user account, User ID #1, an Admin for the site, so I should have permission to do everything.

The site is setup using the most basic discourse_docker config with the standalone template.

Note we’ve tried this as two different admins with two different API keys… One on a Mac OS X workstation and one on an Arch workstation… But same error for both.

Any suggestions?

(Ryan Erwin) #46

The workaround was to remove the assets section from about.json.

  "name": "Dark",
  "about_url": "#",
  "license_url": "#",
  "assets": {
    "fullborders2": "assets/fullborders2.png",
    "greycarbon": "assets/greycarbon3.png"

@sam Any plans to support an assets section in with the CLI tool, or does it already work but I just missed something?

(Jeff Wong) #47

That’s strange, it’s supported sofar as I know - I’ve been using the cli tool for the past month pretty frequently and never ran into an issue with assets.

(Ryan Erwin) #48


Thank you. That was encouragement to keep looking…
Turns out that we had SPACES in the filename of a few items.
In this case, we had CarbonBigWhite (1).png
Those filenames worked in the /admin tool, but not via the CLI.

So for anyone else who gets:

Make sure you don’t have spaces in any of your filenames… :smiley_cat:

(Sam Saffron) #49

Oh that is a legit bug report @Osama can you add this to your list, allow files to have spaces with the theme cli?

(Justin DiRose) #53

Just wanted to say I’ve been doing some theme development for the last few months (fairly new to it still), and I just installed this tool.

Holy crap.

Thanks for making things a billion times easier!