Same as some of my recent posts: get jekyll serve
working to watch
for changes during a preview of my Jekyll-bootstrap blog.
Since I found the Ruby gems setup too difficult, I switched to Ubuntu on Windows 10 after reading a Ruby setup guide.
The default display settings didn’t look great, so I installed
Ubuntu Mono font. Unluckily, one can’t type Chinese
characters, and the bottom line of tmux keeps jumping up from time
to time. Most importantly, the copy and paste function isn’t
convenient to use: every time I need to paste something, I have to
move the mouse to the top of the window, then right click and select
“Modify” → “Paste”. That’s too slow when compared to <S-Ins>
in
mintty which is shipped with Git for Windows.
However, on WLS, aptitude takes good care of package dependencies. That’s much better for installing necessary stuff for blogging with frameworks like Jekyll.
How can I run WLS using a mintty shell?
Use wsl-terminal.
Firstly, I’ve revised the use of chown
, chgrp
and chmod
, and
learnt the function of umask
.
u
, g
, o
stand for “user”, “group” and “others” respectively.r
, w
, x
can be +
or -
.chmod og-w [target-dir]
.Unfortunately, the Windows 10 bash creates folders and files with
permissions 777 and 666 respectively. The comments for
Microsoft/BashOnWindows#352 solved this problem: instead of
putting umask 022
in /etc/profile
or ~/.profile
, it should be
added in ~/.bashrc
because the login mechanism on WLS is different
from a usual GNU/Linux OS. I think the profiles aren’t process
during WLS startup after having added a simple statement for echoing a
few words in ~/.profile
. Lilred’s method is even better.
sh Added this to your '~/.bashrc' https://git.io/vM0xz source
# Note: Bash on Windows does not currently apply umask properly.
if [ "$(umask)" = "0000" ]; then
umask 022
fi
Secondly, I’ve learnt the meaning of eval
.
user@OWNER-PC:~$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-xiwtTnVlI90S/agent.6636; export SSH_AUTH_SOCK;
SSH_AGENT_PID=5764; export SSH_AGENT_PID;
echo Agent pid 5764;
user@OWNER-PC:~$ ssh-add
Could not open a connection to your authentication agent.
From user456814’s answer on a Stack Overflow question
about SSH authentication agent, we can see that ssh-agent
returns
the commands to be copied, pasted and ran in the terminal. The
command eval
saves these steps by taking the output as the command
input.
Same as the background in my previous article.
I uninstalled Ruby 2.0 in the Control Panel, and then installed version 2.3.3 from RubyInstaller for Windows
Gem::InstallError: The 'RedCloth' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing RedCloth (4.2.9), and Bundler cannot
continue.
Make sure that `gem install RedCloth -v '4.2.9'` succeeds before bundling.
The error message is similar to Joe’s gem install error. The only difference is that I was installing RedCloth 4.9.
This failure is due to the absence of a valid path to
RubyInstaller Development Kit. I tried manually adding the
path to the folder for binary executables (default to
C:\RubyDevKit\bin
) to PATH
, but it’s unsuccessful. I googled
“Please update your PATH to include build tools” and found
his question, whose third answer explained the function
of devkitvar.bat
. This batch script actually prepended the path of
two folders into PATH
. One is stated above; one is
C:\RubyDevKit\mingw\bin
. Running this batch file changes PATH
temporarily. A manual configuration in the Control Panel allowed
the system to detect DevKit, and this problem was thus
solved.
Name | Version Number |
---|---|
rake | 10.4.2 |
bundler | 1.13.7 |
Name | Version Number | With native extensions? |
---|---|---|
RedCloth | 4.2.9 | ✓ |
wdm | 0.1.0 | ✓ |
blankslate | 2.1.2.4 | ✗ |
chunky_png | 1.3.4 | ✗ |
coffee-script-source | 1.9.1 | ✗ |
colorator | 0.1 | ✗ |
execjs | 2.4.0 | ✗ |
fast-stemmer | 1.0.2 | ✓ |
ffi | 1.9.6 | ✗ |
hitimes | 1.2.2 | ✓ |
jekyll-gist | 1.1.0 | ✗ |
jekyll-paginate | 1.1.0 | ✗ |
jekyll-sitemap | 0.8.0 | ✗ |
kramdown | 1.6.0 | ✗ |
liquid | 2.6.2 | ✗ |
mercenary | 0.3.5 | ✗ |
multi_json | 1.11.0 | ✗ |
posix-spawn | 0.3.10 | ✓ |
rack | 1.6.0 | ✗ |
rb-fsevent | 0.9.4 | ✗ |
redcarpet | 3.2.2 | ✓ |
safe_yaml | 1.0.4 | ✗ |
sass | 3.4.13 | ✗ |
stringex | 1.4.0 | ✗ |
tilt | 1.4.1 | ✗ |
yajl-ruby | 1.2.1 | ✓ |
I put the error message from wdm in a popup dialog.
Owner@Owner-PC MINGW64 /c/github/vincenttam.github.io (source)
$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Using rake 10.4.2
Using RedCloth 4.2.9
Using blankslate 2.1.2.4
Installing hitimes 1.2.2 with native extensions
Using chunky_png 1.3.4
Installing fast-stemmer 1.0.2 with native extensions
Using coffee-script-source 1.9.1
Using execjs 2.4.0
Using colorator 0.1
Using multi_json 1.11.0
Using sass 3.4.13
Using rb-fsevent 0.9.4
Using ffi 1.9.6
Using tilt 1.4.1
Using jekyll-gist 1.1.0
Using jekyll-paginate 1.1.0
Using kramdown 1.6.0
Using liquid 2.6.2
Using mercenary 0.3.5
Installing posix-spawn 0.3.10 with native extensions
Installing yajl-ruby 1.2.1 with native extensions
Installing redcarpet 3.2.2 with native extensions
Using safe_yaml 1.0.4
Using jekyll-sitemap 0.8.0
Using rack 1.6.0
Using stringex 1.4.0
Installing wdm 0.1.0 with native extensions
Using bundler 1.13.7
Installing parslet 1.5.0
Installing timers 4.0.1
Installing classifier-reborn 2.0.3
Installing coffee-script 2.3.0
Installing compass-core 1.0.3
Installing compass-import-once 1.0.5
Installing jekyll-sass-converter 1.3.0
Installing sass-globbing 1.0.0
Installing rb-inotify 0.9.5
Installing haml 4.0.6
Installing pygments.rb 0.6.2
Installing rack-protection 1.5.3
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wdm-0.1.0/ext/wdm
C:/Ruby23-x64/bin/ruby.exe -r ./siteconf20170109-8020-1n4s35m.rb extconf.rb
checking for main() in -lkernel32... yes
checking for windows.h... yes
checking for ruby.h... yes
checking for HAVE_RUBY_ENCODING_H... yes
creating Makefile
To see why this extension failed to compile, please check the mkmf.log which can
be found here:
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wdm-0.1.0/ext/wdm
make "DESTDIR=" clean
current directory: C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wdm-0.1.0/ext/wdm
make "DESTDIR="
generating wdm_ext-x64-mingw32.def
compiling entry.c
In file included from entry.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from entry.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from entry.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from entry.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling memory.c
In file included from memory.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from memory.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from memory.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from memory.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling monitor.c
In file included from monitor.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from monitor.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from monitor.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from monitor.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling queue.c
In file included from queue.c:3:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/vadefs.h:13:0,
from
4-mingw32/include/_mingw_stdarg.h:14,
from
4-mingw32/include/stdarg.h:140,
from
c:\rubydevkit\mingw\bin\../lib/gcc/x86_64-w64-mingw32/4.7.2/include/stdarg.h:1,
from queue.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from queue.c:3:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from queue.c:3:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling rb_change.c
In file included from rb_change.c:4:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdlib.h:9,
from rb_change.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from rb_change.c:4:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from rb_change.c:4:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling rb_monitor.c
In file included from rb_monitor.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from rb_monitor.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from rb_monitor.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from rb_monitor.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
rb_monitor.c: In function 'rb_monitor_run_bang':
rb_monitor.c:508:9: warning: implicit declaration of function
'rb_thread_blocking_region' [-Wimplicit-function-declaration]
compiling utils.c
In file included from utils.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from utils.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from utils.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from utils.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
compiling wdm.c
In file included from wdm.c:1:0:
wdm.h:3:0: warning: "WINVER" redefined [enabled by default]
In file included from
4-mingw32/include/crtdefs.h:10:0,
from
4-mingw32/include/stdio.h:9,
from wdm.h:1,
from wdm.c:1:
4-mingw32/include/_mingw.h:248:0:
note: this is the location of the previous definition
In file included from wdm.c:1:0:
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
<command-line>:0:0: note: this is the location of the previous definition
In file included from c:/Ruby23-x64/include/ruby-2.3.0/ruby/win32.h:41:0,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/defines.h:168,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby/ruby.h:36,
from c:/Ruby23-x64/include/ruby-2.3.0/ruby.h:33,
from wdm.h:12,
from wdm.c:1:
4-mingw32/include/winsock2.h:15:2:
warning: #warning Please include winsock2.h before windows.h [-Wcpp]
linking shared-object wdm_ext.so
rb_monitor.o: In function `rb_monitor_run_bang':
C:\Ruby23-x64\lib\ruby\gems\2.3.0\gems\wdm-0.1.0\ext\wdm/rb_monitor.c:508:
undefined reference to `rb_thread_blocking_region'
collect2.exe: error: ld returned 1 exit status
make: *** [wdm_ext.so] Error 1
make failed, exit code 2
Gem files will remain installed in
C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/wdm-0.1.0 for inspection.
Results logged to
.out
An error occurred while installing wdm (0.1.0), and Bundler cannot continue.
Make sure that `gem install wdm -v '0.1.0'` succeeds before bundling.
From the line
wdm.h:4:0: warning: "_WIN32_WINNT" redefined [enabled by default]
I found wdm issue #18, but I failed to notice that the problem had been resolved. I later knew that from Jekyll issue #3721.
After changing the version number of wdm to 0.1.1, I could proceed further. The system output was fine.
Owner@Owner-PC MINGW64 /c/github/vincenttam.github.io (source)
$ gem install wdm -v '0.1.1'
Building native extensions. This could take a while...
Successfully installed wdm-0.1.1
Parsing documentation for wdm-0.1.1
Installing ri documentation for wdm-0.1.1
Done installing documentation for wdm after 0 seconds
1 gem installed
Owner@Owner-PC MINGW64 /c/github/vincenttam.github.io (source)
$ bundle install
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/..
Fetching dependency metadata from https://rubygems.org/.
Resolving dependencies...
Using rake 10.4.2
Using RedCloth 4.2.9
Using blankslate 2.1.2.4
Using hitimes 1.2.2
Using chunky_png 1.3.4
Using fast-stemmer 1.0.2
Using coffee-script-source 1.9.1
Using execjs 2.4.0
Using colorator 0.1
Using multi_json 1.11.0
Using sass 3.4.13
Using rb-fsevent 0.9.4
Using ffi 1.9.6
Using tilt 1.4.1
Using jekyll-gist 1.1.0
Using jekyll-paginate 1.1.0
Using kramdown 1.6.0
Using liquid 2.6.2
Using mercenary 0.3.5
Using posix-spawn 0.3.10
Using yajl-ruby 1.2.1
Using redcarpet 3.2.2
Using safe_yaml 1.0.4
Using jekyll-sitemap 0.8.0
Using rack 1.6.0
Using stringex 1.4.0
Using wdm 0.1.1 (was 0.1.0)
Using bundler 1.13.7
Using parslet 1.5.0
Using timers 4.0.1
Using classifier-reborn 2.0.3
Using coffee-script 2.3.0
Using compass-core 1.0.3
Using compass-import-once 1.0.5
Using jekyll-sass-converter 1.3.0
Using sass-globbing 1.0.0
Using rb-inotify 0.9.5
Using haml 4.0.6
Using pygments.rb 0.6.2
Using rack-protection 1.5.3
Installing toml 0.1.2
Installing celluloid 0.16.0
Installing jekyll-coffeescript 1.0.1
Installing compass 1.0.3
Installing sinatra 1.4.5
Installing listen 2.8.5
Installing jekyll-watch 1.2.1
Installing jekyll 2.5.3
Installing octopress-hooks 2.6.0
Installing octopress-date-format 2.0.2
Bundle complete! 14 Gemfile dependencies, 50 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
Post-install message from compass:
Compass is charityware. If you love it, please donate on our behalf at http:
//umdf.org/compass Thanks!
When I ran rake preview
, the follow line appeared.
bash: /c/Ruby23-x64/bin/rake: C:/Users/Justin/Projects/rubyinstaller/sandbox/rub
y23_mingw/bin/ruby.exe: bad interpreter: No such file or directory
I searched “rake install justin projects” on Google.
You may follow griest’s advice to have this problem
fixed. If this link were unluckily dead in the future, you might
leave a comment below after getting rid of Justin at the first line of
/c/Ruby23-x64/bin/rake
.
Octopress did work on my machine. Then I re-ran bundle install
under the local repository for my another blog, but the
same Celluloid error re-appeared. I don’t know how to
perform a celluloid downgrade to version 16.0 under that
repository. The version number for Celluloid was generated by the
system—I didn’t type it in Gemfile.lock
. As a result, I
switched to Ubuntu on Windows 10.
This Git for Windows upgrade from v2.8 to v2.11 is an
unsuccessful attempt to fix a Jekyll preview error on
my another blog triggered by the command jekyll serve
for
local preview.
After the update, I can no longer input letters with accents. Since the name of some mathematical theorems have accents, like l’Hôpital’s Rule. It would be very inconvenient if the internation keyboard can’t be used in Git Bash.
In Git Bash, locale
returns several lines. The first one says
LANG=C
. After viewing the list with locale -a
, I’ve finally
chosen the most common option with the character encoding UTF-8. To
make this change permanent for one user, add the last line into
~/.bashrc
.
1
2
# Change Locale Permanently
export LANG=en_US.utf8
Many popular URL shorteners like Bitly and Google URL Shortener won’t afftect my SEO, so I can use shortened URLs in the markdown syntax for Octopress codeblocks to save disk space.1
Do URL Shorteners Impact your SEO? by David Amerland. ↩
After an upgrade to M$ Win* 10, I connected to my campus’ public Wi-Fi.1
I mistakenly thought that it’s the same as the one described in Windows Security popup window pops up each time any connection is made on Super User.
Googling “windows security login popup”, one will find the question “Windows Security” popup asking me to enter my login information when visiting campus website on M$ Community site. Follow the steps described in the first answer from Azam, a support engineer.
To save disk space, I don’t keep M$ IE due to M$ Edge, which was shipped with the M$ Win* 10 upgrade, and in which the security tab is absent.
To set a custom security level for Internet options without M$ IE, open the same window by clicking Control Panel → Network and Internet → Internet Options. The button “Custom level” will then appear. However, under “User authentication”, there’s no checkboxes. I only saw a group of four radio buttons.
In order to find out the right choice, I appended “custom security level” in the previous Google query. According to a similar page on SysAid, I’ve chosen “Automatic log-on with current user name and password”.
Actually, the popup window prompts for the user name and password for another Wi-Fi network with a similar name to which I’m going to connect. After typing the right user name and password, I can connect to the Internet.
Although Windows Security popup window is the main focus of this blog, I’ve learnt something quite different from it because of the article Windows 10 Settings You Should Change Right Away available on Laptop Mag found during this process. The UAC is really important: by prompting for user’s confirmation during the installation of a new software, one will be aware of the apps installed on the machine. Though many users claim that those who oppose the disablement of UAC are “misinformed”, I take the words of a preferred user who says that M$ Win* 10 would become unstable if it’s been turned off.
c.f. Jekyll Serve Error (2) ↩