I have a jekyll based blog. When I try to build it I get this error:
...
Generating...
Jekyll Feed: Generating feed for posts
Warning on line 1, column 1 of /home/john/Projects/blackblog/assets/css/index.sass:
This selector doesn't have any properties and won't be rendered.
╷
1 │ ---
│ ^^^
╵
Warning on line 2, column 1 of /home/john/Projects/blackblog/assets/css/index.sass:
This selector doesn't have any properties and won't be rendered.
╷
2 │ ---
│ ^^^
╵
Error: This file is already being loaded.
┌──> /home/john/Projects/blackblog/assets/css/index.sass
4 │ #import index, font, basic, layout
│ ^^^^^ new load
╵
┌──> /home/john/Projects/blackblog/assets/css/classes.sass
1 │ #import index, highlight
│ ━━━━━ original load
╵
/home/john/Projects/blackblog/assets/css/index.sass 4:9 #import
/home/john/Projects/blackblog/assets/css/classes.sass 1:9 root stylesheet
Conversion error: Jekyll::Converters::Sass encountered an error while converting 'assets/css/classes.sass':
This file is already being loaded.
...
This code of whole site: github.com/yagarea/blackblog.
What should I fix to make my site build ?
Thank you for help
Cause of this issue was that I had file name index.sass in _sass and in assets. This was not issue in until jekyll-sass-converter version 3.0.
I renamed one file to main.sass. I brought a lot of other issues but it was easy fix because build log tells you what to do to fix it.
Not really a bug. This is how it happened:
index.sass has front matter. Jekyll read file as string, process and remove the front matter, then start to compile an input “string”.
index.sass imports index.sass, according to sass spec, the relative import of itself hits before load path, and now we are importing the same file which technically is a circular import. When sass read the same input directly from disk, it knows nothing about the Jekyll front matter and would give up with a syntax error.
One way to address it can be write a custom importer that checks for front matter in each imported partials, and compile it with Jekyll before read as sass partials. However, this has significant drawbacks that isn’t worth doing:
Jekyll’s sass implementation has never allowed partials to have front matters.
Allowing front matter in partials would lead to slower compilation performance as every partial need to be preprocessed by Jekyll, and then passed through protobuf via stdio as a string rather than dart-sass-embedded directly read file from disk.
Even if we allow front matter in partials, it would still be circular import, and user would just get a different error message.
Source: github.com/jekyll/jekyll/issues/9265
Related
It took me hours to figure out how to patch the below code. The path to it was very much unexpected.
Depending on how I run the tests, and which dir I am in, I find the dotted path to the module to patch changes. This is really bad for unittesting. Which makes me think I am doing it wrong.
The file structure related to the code is:
loaders.py <-- Has a load_palette() func required to be patched
typers.py <-- Has `from . loaders import load_palette`, and calls load_palette()
render.py <-- Has a func that calls the typers func
tests/test_render.py <-- Tests for render which calls a func in render, which calls a func in typers, which calls load_palette()
In the code below __package__.replace('.tests', '.typers.load_palette') takes the current path to the current package which could be:
bar.tests or
foo.bar.tests
or something else
and builds the dotted path relatively so that is is correct. This seems very hackish. How is one supposed to safe guard against these kind of issues?
Ideally the dotted path would be ..typers.load_palette but it did not accept the relative dotted path.
Heres the actual code:
# file: test_render.py
# Depending where one runs the test from, the path is different, so generate it dynamically
#mock.patch(__package__.replace('.tests', '.typers.load_palette'), return_value=mocks.palette)
class render_rule_Tests(SimpleTestCase):
def test_render_preset_rule(self, _): # _ = mocked_load_palette
...
files layout as following:
$ tree issue
issue
├── __init__.py
├── loaders.py
├── renders.py
├── tests
│ ├── __init__.py
│ └── test_render.py
├── run_tests.sh
└── typers.py
1 directory, 7 files
the root package is issue, you should always import modules from issue, and patch issue.xxx.yyy.
then run pytest (or some other unittest tools) from the same path as tests resident.
for example, run_tests.sh is a shell script to run all test cases under tests.
and test_render may be like this
# file: test_render.py
# Depending where one runs the test from, the path is different, so generate it dynamically
#mock.patch('issue.typers.load_palette', return_value=mocks.palette)
class render_rule_Tests(SimpleTestCase):
def test_render_preset_rule(self, _): # _ = mocked_load_palette
...
You can add the path of the "tests" directory using sys.path.insert.
In the top of "tests/test_render.py" add:
import sys
sys.path.insert(0, "<path/to/the/folder/tests/>")
# Depending where one runs the test from, the path is different, so generate it dynamically
#mock.patch(__package__.replace('.tests', '.typers.load_palette'), return_value=mocks.palette)
class render_rule_Tests(SimpleTestCase):
def test_render_preset_rule(self, _): # _ = mocked_load_palette
...
This will add the path in system paths where python interpreter. From there, the python interpreter can locate the relative imports.
Note: The safest option would be to add the absolute path to the tests folder. However, if it's not possible, add the shortest relative path possible.
I'm trying to import the stylesheet like this #import"../../../../styles/forms.scss";
But I get this error:
ERROR in Module build failed (from ./node_modules/sass-loader/dist/cjs.js):`
SassError: Can't find stylesheet to import.`
1 │ #import"../../../styles/variables.scss";
(it goes back three times instead of four like in my path)
Then when I go back once more (just to test) "../../../../../styles/forms.scss", VS Code goes back 5 times. I know the path I'm typing is right. I am using Angular if it matters.
Apparently I imported variables.scss within my forms.scss file and when I called forms.scss one level deeper, it couldn't find variables.scss with the path I specified in forms.scss.
Now I removed variables.scss from forms.scss and added them separately to each file and it works.
I have a file located at
content/post/data_for_posts/my_file.md
I have it there because it's quite easy to do htmltools::includeMarkdown("data_for_posts/my_file.md") and recycle this file in different posts.
My problem is that when I serve_site() this creates a public/post/data_for_posts/index.html, which means, it gets posted to my website (as a January 1 of 0001). I guess I could change the date to year 10000, but I would rather handle it the way I handle the .Rmd and other files, as suggested here
I have tried to modify my config.toml but have not managed to solve the issue.
ignoreFiles = ["\\.Rmd$", "\\.Rmarkdown$", "_files$", "_cache$", "content/post/data_for_posts/my_file.md"]
Here are a couple techniques that I use to do this:
Rename data_for_posts/my_file.md so it uses a file extension that hugo does not interpret as a known markup language, for example change .md to .markd or mdn.[*]
Rename data_for_posts/my_file.md so it includes a string that you will never use in a real content file, for example data_for_posts-UNPUBLISHED/my_file.md. Then add that string (UNPUBLISHED or whatever) to your config ignoreFiles list.[**]
[*] In the content/ directory, a file with one of the following file extensions will be interpreted by hugo as containing a known markup language: .ad, .adoc, .asciidoc, .htm, .html, .markdown, .md, .mdown, .mmark, .pdc, .pandoc, .org, or .rst (this is an excerpt of something I wrote).
[**] The strings listed in ignoreFiles seem to be case sensitive so I like to use all-upper-case characters in my ignored file names (because I never use upper-case chars in real content file names). Also note that there is no need to specify the path and my experience is that path delimiters (/ or \) cause problems.
My filesystem tree looks like this:
C:.
└───static
├───custom_stuff
│ presets.css
│ presets.less
│
└───index
index.less
So, why index.less can't find presets.less, and throws me an error:
'/static/custom_stuff/presets.less' wasn't found. Tried -
/static/custom_stuff/presets.less
I'm using VS Code and this extension to compile LESS to CSS
Your path will be ../custom_stuff/presets.less
I have code that intends to iterate through a directory hierarchy, and, for every file at the bottom of the hierarchy, create a file.
for currentDirectory, listOfSubDirectories, listOfStructures in os.walk(projectsLocation):
#this says if we arent at the bottom of the directory chain, do nothing (checks if subDirectoryList is 0)
if not listOfSubDirectories:
##THIS IS WHERE WE DO THINGS FOR ONE SIMULATION##
for currentStructure in listOfStructures:
if "Abridged" in currentStructure:
os.remove(currentStructure)
abridgedVersion=open(currentStructure[:-4]+"Abridged","w+")
Extremely bizarrely, however, is that the code places 2 of the files files at the top of the directory!
Even stranger is that when i rerun the code with error-checking print statements, printing the three lists, the files that get printed at the top of the directory "cant be found" despite the fact that they arent even in the list of files!
i.e.
/home/parker/pretendFoldingData/proj8202/run2/clone1
[]
['structure1.pdb', 'structure0Abridged', 'structure0.pdb']
Traceback (most recent call last):
File "importAtomFileMaker.py", line 35, in <module>
os.remove(currentStructure)
FileNotFoundError: [Errno 2] No such file or directory: 'structure1Abridged'
I hope this was even slightly clear..... can someone please advise?
from a friend:
You have a bug in your code;
well at least 2.
Especially if you are trying to rename a file.
open("path", 'w+') creates a file relevant to the current working directory unless a absolute path is given. Fix this by doing
base_path = os.path.join(currentDirectory, structure)
then
open(base_path + <filename>, 'w+') ...
This will make sure that the file you create will be placed relative to the current directory.
Instead of removing the file then creating a blank one, just rename the file
also the if not listOfDirectories is a bit "hacky".
I think your better off regex-ing the current directory for a pattern that you expect to be true