When trying to run bundle exec jekyll serve on a Windows 10 machine, this error occurs:
jekyll 3.7.4 | Error: File to import not found or unreadable: reset.
Load paths:
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/minima-2.5.0/_sass
C:/Ruby25-x64/lib/ruby/gems/2.5.0/gems/minima-2.5.0/_sass on line 6
My directory structure is as follows:
.
├── _config.yml
├── README.md
├── _sass
| ├── _reset.scss
| └── _variables.scss
├── assets
| ├── styles
| | └── design.scss
├── .gitignore
├── Gemfile
├── Gemfile.lock
└── index.md
Please note that this works on my Mac (I just cloned the git repository and tried to serve on Windows).
I've tried adding this to _config.yml but it did not change anything.
sass:
sass_dir: _sass
I switched from "native Windows" to docker to build my Jekyll pages.
Jekyll on Docker Hub.
Create the folder $PWD/vendor/bundle before using docker.
docker run -it --rm \
--volume="$PWD:/srv/jekyll" \
--volume="$PWD/vendor/bundle:/usr/local/bundle" \
jekyll/jekyll \
jekyll build
Related
I'm building a gem with Rust and I need to know how to run the Rust compiler when installing the gem. With a C-extension, I can use mkmf to generate a Makefile. But how can I run cargo build --release?
The directory structure looks like this:
.
├── bin
│ ├── console
│ └── setup
├── CODE_OF_CONDUCT.md
├── Gemfile
├── Gemfile.lock
├── lib
│ ├── rmpd_adschedule
│ │ └── version.rb
│ └── rustgem.rb
├── LICENSE.txt
├── Rakefile
├── README.md
├── rustgem.gemspec
├── rust
│ ├── Cargo.lock
│ ├── Cargo.toml
│ └── src
│ └── lib.rs
└── spec
├── rustgem.rb
└── spec_helper.rb
I've created a Rake task to build the Rust library:
task :compile do
sh "cd #{File.dirname(__FILE__)}/rust && cargo build --release"
end
But how to run this Rake task when installing the gem? Or how to generate a suitable Makefile with mkmf? The Makefile should look like this:
all:
cd rust/ && cargo build --release
But it doesn't work if I put it into the root directory, and I don't know how to tell mkmf to generate this exact Makefile.
I found one stupid way to do this when the gem is loading:
module Rustgem
system("cd #{File.dirname(__FILE__)}/../rust && cargo build --release")
end
But this is not a good solution.
Turns out I can do this:
# rust/extconf.rb
require 'mkmf'
create_makefile 'rust/rustgem'
system("cd #{File.dirname(__FILE__)} && cargo build --release")
In this case, create_makefile will create an empty Makefile. Then make will return 0 make: Nothing to be done for 'all'. which is what we need, and then system call will do the work.
Or somewhat better:
require 'mkmf'
create_makefile 'rutgem'
File.write('Makefile', "all:\n\tcargo build --release\nclean:\n\trm -rf target\ninstall: ;")
I'm not sure if this is good solution. If you know a better one please tell it.
UPDATE
Actually, you can put Makefile along with empty extconf.rb in the same directory and it will work. Blog post about Ruby-Rust integration: http://undefined-reference.org/2016/05/14/writing-rubygem-in-rust.html
I am on mac and Installed maven using the brew install maven command. The maven was installed in /usr/local/Cellar/maven/3.3.9 path. Then i edited my ~/.bash_profile file and put the following entries
export M2_HOME="/usr/local/Cellar/maven/3.3.9"
export PATH="$PATH:$M2_HOME/bin"
now when i try mvn -version maven throws the error that
Error: Could not find or load main class org.codehaus.plexus.classworlds.launcher.Launcher
Did i configure it wrong ?
EDIT: Maven folder
$ tree -L 2 $M2_HOME
/usr/local/Cellar/maven/3.3.9
├── INSTALL_RECEIPT.json
├── LICENSE
├── NOTICE
├── README.txt
├── bin
│ ├── mvn
│ ├── mvn.cmd
│ ├── mvnDebug
│ ├── mvnDebug.cmd
│ └── mvnyjp
└── libexec
├── bin
├── boot
├── conf
└── lib
I have also seen as an option:
Create a file ~/.MacOSX/environment.plist with:
{
"M2_HOME" = "/usr/local/Cellar/maven/3.3.9/libexec";
"M2" = "/usr/local/Cellar/maven/3.3.9/libexec/bin";
}
and restart / log back in. This would make tools like IntelliJ also pick it up.
However in my case, I found some other setup script had installed an export for M2_HOME in my .profile which broke the maven install.
How do I force middleman to reload when I edit the data file?
For example. This is my app:
├── Gemfile
├── Gemfile.lock
├── config.rb
├── data
│ └── products.yml
└── source
├── ...
When I edit data/products.yml the data does not appear on the site until I manually restart the server with bundle exec middleman.
It works if you manually add data to the reload paths
middleman server --reload-paths data/
https://github.com/middleman/middleman/issues/726
I am developing a ruby gem which will have a binary.
I am trying to develop the binary but i am worried its not finding my requires because the gem isnt installed as a gem is there a way to test the binary without packaging it as a gem?
#!/usr/bin/env ruby
require "middleman_ember_scaffold/load_paths"
# Start the CLI
MiddlemanEmberScaffold::Cli::Base.start
sits in a file named mse and ive added my bin folder of gem to path
.
└── middleman_ember_scaffold
├── Gemfile
├── LICENSE.txt
├── README.md
├── Rakefile
├── bin
│ └── mes
├── lib
│ ├── middleman_ember_scaffold
│ │ ├── cli.rb
│ │ ├── load_paths.rb
│ │ └── version.rb
│ └── middleman_ember_scaffold.rb
└── middleman_ember_scaffold.gemspec
4 directories, 10 files
when i run mes i get
/Users/justin/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- middleman_ember_scaffold/load_paths (LoadError)
from /Users/justin/.rvm/rubies/ruby-1.9.3-p362/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
from /Users/justin/middleman-generator/middleman_ember_scaffold/bin/mes:7:in `<main>'
i'd like to be able to run and develop mes without re-packaging everytime i make a change.
Probably a "better" way would be to do the following:
$ ruby -I./lib bin/mes
It does the same as changing your load path, but it only does it for the command you're executing.
Use RUBYLIB Environment Variable
The problem you're facing is that your source directory isn't getting some of magic applied to installed gems, and therefore doesn't have your lib directory in the $LOAD_PATH. While there are other ways to deal with this, for testing I'd recommend just adding your lib directory to the RUBYLIB environment variable. For example:
RUBYLIB="/path/to/middleman_ember_scaffold/lib:$RUBYLIB"
export RUBYLIB
bin/mes
should work for any Bourne-compatible shell. If you're running Bash, and don't have anything else stored in RUBYLIB, you might even be able to shorten the invocation to:
RUBYLIB="/path/to/middleman_ember_scaffold/lib" bin/mes
Either way, once Ruby knows what directories it should add to the $LOAD_PATH everything should work just fine.
Is there an easy way to fire up a web browser for a folder?
eg.
I am in a folder that contains a website (index.html and other files) and I want to browse the site through a browser. Is there a gem that I just launch to make this folder browsable?
In this way I don't have to install nginx just for a specific folder. And when you install nginx you have to bother with configuration files and so on.
Kinda how Rails does it with:
rails server
Yes, there is... Throw the following in a file called webserver:
#!/usr/bin/env ruby
require 'webrick'
include WEBrick
server = HTTPServer.new(:Port => 3000, :DocumentRoot => Dir::pwd)
trap("INT"){ server.shutdown }
server.start
Then, perform the following (This assumes Mac OSX):
$ sudo chmod 755 webserver
$ sudo chown root:wheel webserver
$ sudo cp webserver /usr/local/bin/webserver (or somewhere in your path)
Now, just run webserver from the directory you want to use as the document root. A webserver will now be running on localhost:3000.
Hope this helps!
UPDATE
I just remembered after reading a post on Phusion Passenger 3.0 progress that there will be a passenger lite option...
Easiest way I've found is this little Python one-liner:
2.x:
python -m SimpleHTTPServer
3.x:
python -m http.server 8080
Unless you want to execute Ruby dynamically, of course. But that wasn't explicit in your question. Only static HTML.
The webbrick example works great, thanks to Brian. However, I just wanted to follow up on his update.
Assuming you have a working ruby and rubygems installed:
gem install passenger
put all files in a subdirectory called public
example project dir:
.
├── any
│ ├── old crap
│ └── that will not be on the website
└── public
├── favicon.ico
├── images
│ ├── ajax-loader-large.gif
│ ├── bg.jpg
│ ├── bg_home.jpg
│ ├── bg_nav.gif
├── index.html
├── javascripts
│ ├── jquery.liveSearch.js
├── robots.txt
└── stylesheets
├── all.css
Then run passenger start
The first time it will install a bunch of things (including nginx, but you won't have to worry about configuring it), but it should work faster after that.
And, if you have PHP >= 5.4.0, you can:
php -S localhost:8000
That's pretty easy!
Reference: http://php.net/manual/en/features.commandline.webserver.php