I am following Michael Hartl's Learn Enough CSS course. My current folder layout is as follow:
- _layouts
- _site
index.html
where index.html is:
---
layout: test
---
and I have test.html in _layouts as:
Hello again, world.
Whenever I run jekyll serve, I get this error:
Error reading file /Users/pj/Documents/LETGD/repos/pohjie.github.io/_layouts/test.html: no implicit conversion of Hash into Integer
Error reading file /Users/pj/Documents/LETGD/repos/pohjie.github.io/index.html: no implicit conversion of Hash into Integer
Does anyone have any idea what's happening? I'm using M1 MacBook, not sure if that is a possible cause as I spent a lot of time install Ruby as well.
Thanks!
While downgrading certainly works, it may be pretty annoying and (depending on where you need this) problematic. If you just want a simple workaround, you can make use of the fact that jekyll build still works with Ruby 3 and just serve the page separately:
bundler exec jekyll build && bash -c 'cd _site && python -m http.server 3000'
The only downside of this is that you lose the automatic reload. If you change anything, you need to restart jekyll. But you can run this in a Ruby 3 environment without fiddling with the environment itself.
Quoting from this source:-
Github-Pages uses Jekyll 3.9, which isn’t compatible with Ruby 3.
Downgrading to Ruby 2.7 should avoid the problem.
This worked for me.
Downgrading to Ruby 2.7 is an option (as others have said) which I didn't feel like doing, so I did this instead:
Apply the patch to pathutil
From Liviu Stefan's answer:
Ruby 3.0 deprecated using the last argument as keyword parameters. A double splat ** has to be added before the variable for the behavior to be supported.
Here's how I applied the patch locally:
sudo sed -i.bak 's/, kwd/, **kwd/' $(gem which pathutil)
After that I got another error:
/var/lib/gems/3.0.0/gems/jekyll-3.9.0/lib/jekyll/commands/serve/servlet.rb:3:in `require': cannot load such file -- webrick (LoadError)
Which I fixed by running (from bundle exec jekyll serve: cannot load such file):
bundle add webrick
Ruby 3.0 deprecated using the last argument as keyword parameters. A double splat ** has to be added before the variable for the behavior to be supported.
It's fairly straightforward to amend locally; the relevant patch is found: here
Which needs to be applid to:
/home/<your_user_name>/gems/gems/pathutil-0.16.2/lib/pathutil.rb
Related
While trying to install Perl modules like JSON::XS or YAML::XS, i receive the same error:
XS.xs:1:10: fatal error: 'EXTERN.h' file not found
I use MacBook, xCode is up to date, everything else that could help is up to date too.
Since OS X El Capitan, Apple introduced System Integrity Protection which restricts writing to /usr/lib /usr/bin and other sensitive directories (even to root or sudo user) that are used by the installation of Perl bundled with the Operating System. This can cause issues when it comes to installing new modules and also if trying to install XS modules ( those linked to external C libraries ).
For this reason you should not consider the default Perl installation as a working development environment, especially if you are installing custom modules.
Check out this thread on PM and others. I had since El-Capitan managed to solve this before by manually building from tarball and adding a few params or environment variables to set the paths believing that it would be best to retain use of the system Perl but this is not the way to go. This makes your environment difficult to build but also brittle and sensitive to OS updates that may either break things in many different ways.
The best practice seems to be starting with a Perl using brew install perl and work in this environment, remembering to setup your bash_profile as directed by the installer.
Also worth remembering to do a brew link perl. If you receive warnings about this clobbering what looks like system Perl libraries don't worry - these are likely modules that were installed by you over the top and it will cause you less trouble to link over these. If you have concerns, make a note of which module installs will be cleared and re-install them once your environment is configured ( ie your module installer approach is configured using cpanm or sticking with the old perl -MCPAN -e shell etc)
This new Perl setup from brew eliminates the need to continuing running sudo which adds another layer of things that can go wrong as environment variables don't follow through and permission conflicts arise etc.
Finally to simplify package/module installation I suggest doing a brew install cpanminus. If you had previously already installed this, you can ensure the paths etc are configured by doing a brew reinstall cpanminus
If you want to take it another step further then you can install perlbrew as well which will give you the ability to run multiple versions of Perl as your user and configure these with their own libs and modules which can be very useful particularly if aligning with your production environment for testing etc.
One problem you may face if moving from system Perl to this kind of approach is needing to deal with any hangovers from installing things with sudo. It wis worth taking a little time to get all this set up right though and your issues going forward will be greatly reduced and you won't be left with that nagging feeling that you don't want to change anything for fear of it all breaking.
I have also come across a Perl Blog Article that suggests a fix for XS issues with perlbrew on Mojave
This Gist described updating your cpan shell install root though this shouldn't be necessary unless your cpan is stuck in an old config after taking steps above.
I've also raised this as a new issue on PerlMonks
After reading https://developer.apple.com/documentation/xcode_release_notes/xcode_10_release_notes#3035624 and installing the Additional headers via
sudo installer -pkg /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg -target /
I successfully compiled without the missing 'EXTERN.h' error
In order to follow the common advice I also tried with Perlbrew to install a dedicated development version of Perl. Especially with the advice in mind First, do not use the system Perl on MacOS. The installed version is for Apple, not for you (see the discussion here: https://www.perlmonks.org/?node_id=1224727).
Unfortunately, the following error occurred:
Test Summary Report
-------------------
porting/libperl.t (Wstat: 65280 Tests: 35 Failed: 0)
Non-zero exit status: 255
Parse errors: No plan found in TAP output
Files=2653, Tests=1217766, 708 wallclock secs (52.74 usr 9.40 sys + 395.38 cusr 49.90 csys = 507.42 CPU)
Result: FAIL
make: *** [test_harness] Error 1
##### Brew Failed #####
Therefore, I decided to install it the following way (and not following the advice due to the error).
Even after having the above mentioned macOS SDK headers already installed on Catalina (macOS 10.15.2) it didn't work for me. I faced the issue during the installation of the Perl module Mac-SystemDirectory-0.13. The following steps (by identifying the missing file in hope of having a more generic approach for more or less equivalent issues) did the trick:
Locate the header file (in this case EXTERN.h)
sudo find /Library -type f -name EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.28/darwin-thread-multi-2level/CORE/EXTERN.h
/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/EXTERN.h
Ensure the installed Perl version (here 5.18) match the header file:
perl -v | grep version
This is perl 5, version 18, subversion 4 (v5.18.4) built for darwin-thread-multi-2level
Export the path for the C-Compiler (note MacOSX10.15.sdk for Catalina and Perl Version 5.18)
export CPATH=/Library/Developer/CommandLineTools/SDKs/MacOSX10.15.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE
Invoke the Makefile.PL with perl
perl Makefile.PL
BTW — For anybody who's still struggling with this, my workaround was:
bash% module="Sub::Util" # For example
bash% cpanm --configure-args="INC=-I/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE" "$module"
Please try this
CPATH=$(dirname $(find /usr/local/Cellar/ -name EXTERN.h)) cpan JSON::XS
For Big Sur and perl 5.30, EXTERN.h is at /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk/System/Library/Perl/5.30/darwin-thread-multi-2level/CORE
I'm trying to upgrade CPAN itself and got that error. But I have /usr/bin/cpan and I can't write there so I have to tweak it to write the updated version to /usr/local/bin/cpan.
No promises, but yum install perl-devel worked for me.
As #huyz has helpfully pointed out, if you hit this error on a Mac, you don't have this option, even though this is probably your issue, and you need to follow one of the above methods of getting a version of Perl that isn't missing important chunks, as per other answers.
But if, dear reader, you hit this error on a linux host, as I did, then this might be an option for you.
Building on what E Lisse suggested, you might also have luck looking in
/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/
For example:
CPATH=$(dirname $(find /System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/ -name EXTERN.h)) cpan JSON::XS
You could also find where EXTERN.h is located and add that to your shell by default, e.g. in your .bashrc or .zshrc file:
export CPATH=/System/Volumes/Data/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk/System/Library/Perl/5.18/darwin-thread-multi-2level/CORE/
I can't serve a jekyll site locally and I get notified that there is a problem with GitHub pages when I commit to GitHub.
bundle exec jekyll -v 11:28:34
jekyll 3.7.3
ruby --version 11:28:42
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
When I run:
bundle exec jekyll serve
will fail and spit out hundreds (more like thousnads) of error messages starting with:
bundler: failed to load command: jekyll (/usr/local/bin/jekyll)
SystemStackError: stack level too deep
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:106:in `new'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:106:in `add_text'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:171:in `parse_raw_html'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:60:in `handle_kramdown_html_tag'
From what I could tell, this can sometimes happen if you use jekyll serve as opposed to bundle exec jekyll serve and if there is a mismatch between your version of jekyll and the one required by github pages, but here I do use bundle exec and so the correct version of jekyll is used.
jekyll itself works if i try to create a new site with jekyll new blah and i can serve that one locally without a problem, but the combo of jekyll and github pages is giving me grief.
I am puzzled and do not know how to proceed.
All this is on Mac OS X 10.13.6.
Not relating to the original cause of the problem here, but i stumbled upon this and had the error stack level too deep. So i guess this might help someone.
I traced my problem to a field that i named as max in some yaml dictionary in the front matter. Maybe you have named a field which has a special meaning in jekyll.
I looked everywhere and I can't find any help on how to get JRuby to work on AIX. I tried unpacking the binary package, tried using the jruby-complete.jar but I stumble on the same problems.
All errors seem to occur because JRuby is looking in the wrong directories for lib files.
For instance, I set my GEM_PATH=/home/dev999/install_tmp/gem and then I try to require activerecord-jdbc-adapter, which is installed under ./gem/gems/activerecord-jdbc-adapter-1.3.12, but for some reason JRuby keeps looking for the gem under ./gem/gems/activemodel-4.1.8/lib as shown below.
dev-host:/home/dev999/install_tmp$ jruby -e "require 'activerecord-jdbc-adapter'"
Errno::ENOENT: ENOENT - /home/dev999/install_tmp/gem/gems/activemodel-4.1.8/lib/activerecord-jdbc-adapter
file? at org/jruby/RubyFileTest.java:131
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:46
any? at org/jruby/RubyEnumerable.java:1473
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:46
any? at org/jruby/RubyEnumerable.java:1473
contains_requirable_file? at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/basic_specification.rb:44
find_inactive_by_path at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/specification.rb:898
find at org/jruby/RubyEnumerable.java:592
find_inactive_by_path at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/specification.rb:897
try_activate at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems.rb:183
require at /usr/local/jruby-1.7.16.1/lib/ruby/shared/rubygems/core_ext/kernel_require.rb:132
(root) at -e:1
Any insights on what may be causing this are greatly appreciated.
EDIT: The server is an AIX 64 bits; we tried Java 1.6 and 1.7 both 64 and 32 bits (IBM custom build for AIX) but we ended up sticking with 1.7 64 bits in the final solution, although the version doesn't seem to affect the issues found in the Ruby 1.7.9 installation, but since we couldn't get JRuby 1.7.16 to work, I can't be sure if the Java builds we used could have played part in the problem.
OK, so the server admin and I spent two days trying to figure these things out and I can finally summarize the solution we ended up with to get JRuby working on AIX_64.
1 . First and most important of all, I had to install JRuby 1.7.9 since the 1.7.16 stable version from the main download page in jruby.org has many (seemingly AIX specific) bugs that we could not figure out; for instance, the wrong gem path resolution shown in my original question. Version 1.7.9 sorts out most of the issues automatically;
2) For some weird reason that I'm still unable to figure out, jirb won't work with the jline-2.11.jar lib that comes with the downloaded JRuby package. At some point I got it to work but then I could not retrace my steps so I gave up. To sort this issue out I downloaded jline-1.0.jar and replaced the jline jar located under <jruby_path>/lib/ruby/shared/readline/jline-2.11.jar; please note that even if we are replacing this with jline-1.0, the jar file name must still be the same i.e. jline-2.11.jar otherwise jirb will complain about a missing lib;
3) Some common steps: add jruby/bin to $PATH; make sure which java shows the correct Java version you want to use; set $JAVA_HOME;
4) (Optional, but very useful) in order to avoid having to grant my user write access to the /usr/<jruby>/<gem_paths> directories but still allow me to install gems without having to ask the admin I added export GEM_PATH=~/.gem to my .profile, then mkdir ~/.gem. To install gems to my home directory I do jgem install <gem_name> -i $GEM_PATH.
Hopefully this helps other users struggling with the same problems.
My main suggestion is to join the jruby mailing list and ask there. I've used jruby just once and managed to get it working. Here is a bit of magic that I don't really understand that I have at the top of one of the first files I require:
# We need the db2j.jar loaded
require 'db2j.jar'
# Some feaking magic Java needs
Java::JavaClass.for_name 'com.ibm.db2j.jdbc.DB2jDriver'
# The connection string is jdbc:db2j:the/path/to/the/file where the
# file is actually a directory.
CloudscapeDriver = 'jdbc:db2j'
You can see the email thread here: http://comments.gmane.org/gmane.comp.lang.jruby.user/17856
good luck
Per http://jruby.org/2014/01/09/jruby-1-7-10.html, the subject problem is supposed to be fixed in 1.7.10 via https://github.com/jruby/jruby/pull/1252. However, my experience is otherwise, per:
MacbookAir1:javlats palfvin$ jruby -v
jruby 1.7.10 (2.0.0p195) 2014-01-09 c4ecd6b on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
MacbookAir1:javlats palfvin$ jruby
(1..2).size
NoMethodError: undefined method `size' for 1..2:Range
(root) at -:1
MacbookAir1:javlats palfvin$
I haven't figured out how to look at the Java code in an installed JRuby version, so I wasn't able to compare the installed Java source code to the version on github, but this seems so basic it's hard to believe there's anything in my environment that is messing it up. I Googled to see if anyone else had encountered this, but didn't find anything.
Any ideas?
If my git-fu is right, I don't think this commit was included in 1.7.10. Indeed, it looks to only be in master:
$ git show -s --oneline 01be8f85522e4da8df3968e622fa2c947ea6712c
01be8f8 Add a size method to RubyRange to resolve #1252
$ git branch -r --contains 01be8f85522e4da8df3968e622fa2c947ea6712c
upstream/master
upstream/unbox_opts
$ git tag --contains 01be8f85522e4da8df3968e622fa2c947ea6712c
Perhaps there was a confusing merge somewhere in JRuby land?
when i run jekyll --server,it built failed ,and display this :
[2013-01-10 15:34:52] regeneration: 1 files changed
Liquid Exception: Failed to get header. in 2013-01-05-vim.markdown
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:357:
in rescue in get_header'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:338:
inget_header'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:235:
in block in mentos'
C:/Ruby193/lib/ruby/1.9.1/timeout.rb:68:intimeout'
C:/Ruby193/lib/ruby/gems/1.9.1/gems/pygments.rb-0.3.7/lib/pygments/popen.rb:209:
...
i use pygments to highlight my code..
help me !!
Check if your python version is 2.X. Python 3 is unsupported by the pygments.rb gem.
This is giving me headache...: since 2011 it seems that "pygments.rb" is reported to work with Python 3 as per this Jekyll installation guide for windows mentioned in the official Jekyll installation docs "http://www.madhur.co.in/blog/2011/09/01/runningjekyllwindows.html" (which just to blow in more confusion today got an expired domain...)
So yea, how do you install Jekyll, which by the way is described as a Ruby static website generator on its github page - when it:
requires Python while being a Ruby thing
recommends Python 3 leaving you alone to figure out that it only works with Python 2
doesn't say a thing about it after 2 years
Well you simply don't.