New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running `fontcustom compile .` leads to cryptic errors about trying to File.read a direcory. #195

Open
dantman opened this Issue Mar 22, 2014 · 8 comments

Comments

Projects
None yet
3 participants
@dantman
Copy link

dantman commented Mar 22, 2014

I'm trying out FontCustom now and I've been getting errors like:
/Library/Ruby/Gems/2.0.0/gems/fontcustom-1.3.3/lib/fontcustom/base.rb:44:in `read': Is a directory - ./templates (Errno::EISDIR)

I've examined the code and think I figured out why this happens:

  • I run fontcustom compile . (this seems to be what the quick start recommended) for the first time with a config file, no manifest, no output.
  • Options will have :input => '.' implicitly passed in to it.
  • options.rb:set_config_path sets @cli_options[:config] to "fontcustom.yml"
  • options.rb:load_config will then load that config including the :input => { :vectors => '.', :templates => 'templates' }
  • options.rb:merge_options will then override the :input specified in the config and set it to ..
  • options.rb:119 goes and sets :input to { :vectors => '.', :templates => '.' }
  • base.rb:42 adds Dir.glob File.join(@options[:input][:templates], "*") to the list of files to checksum.
  • Because this essentially means ./*, directories such as templates/ app/ assets/ (or whatever you use for your :output directories will be added to the same list as the .svg files.
  • base.rb:42 will iterate over the files, try to File.read a directory, and ruby will throw an exception.

I have found proper ways of running fontcustom now (-c and omitting the path), but I think there are still a few things that should be fixed:

  • base.rb:checksum should not blindly File.read everything, it should consider the possibility of their being a directory, etc... and either ignore it while outputting a warning or exit with a proper error saying something was wrong with the checksum generation instead of an extremely cryptic error that's 100% impossible to understand without reading fontcustom's source code.
  • base.rb:checksum probably shouldn't be blindly checksumming every file in the templates folder, it should be looking at the list of templates used inside the output and only checksumming them. For that matter the possibility that the checksum folder doesn't exist should be considered as most people probably don't use custom templates anyways.
  • options.rb probably should not be overriding :templates when it messes with :input/:vectors, in fact all the code implicitly setting :templates to '.' seems to be just looking for trouble.
    • Another thought I've had is that when getting an unnamed argument from the cli, compile shouldn't even be messing with :input anyways. If a fontcustom.yml config is found inside a specified directory options.rb should instead just use the :input inside of it, unless explicit named --vectors and --templates arguments are passed by the cli.
  • The documentation should be changed. Right now it says there are fontcustom compile path/to/vectors and fontcustom config commands, fontcustom.com even suggests fontcustom config /path/to/vectors. But what it doesn't say is that if you are using a config file you should not be specifying a path/to/vectors when you run fontcustom compile.
@jaydenseric

This comment has been minimized.

Copy link

jaydenseric commented Mar 27, 2014

I have been having nightmares with this cryptic error message.

This is my folder structure:

font-custom-project-filestructure

This is the config:

font_name: icons
no_hash: true
input:
  vectors: svg
  templates: .
output:
  fonts: .
  _icons.scss: ../../styles
templates: [_icons.scss]

Running from the project root:

$ fontcustom watch fonts/icons

I get the error:

/Users/chejss/.rvm/gems/ruby-2.1.1/gems/fontcustom-1.3.3/lib/fontcustom/base.rb:43:in `read': Is a directory @ io_fread - ./svg (Errno::EISDIR) 
@jaydenseric

This comment has been minimized.

Copy link

jaydenseric commented Mar 27, 2014

Anyone know what I have to do to get everything to work in the meantime? I am attempting to use Font Custom on two real-world projects with deadlines...

@dantman

This comment has been minimized.

Copy link

dantman commented Mar 27, 2014

@jaydenseric Try cd'ing into fonts/icons and running fontcustom watch without any arguments.

@jaydenseric

This comment has been minimized.

Copy link

jaydenseric commented Mar 27, 2014

@dantman I have tried that, to exactly the same effect :(

@dantman

This comment has been minimized.

Copy link

dantman commented Mar 27, 2014

@jaydenseric Try deleting the .fontcustom-manifest.json and regenerating everything. The manifest goes and saves/overrides parts of the config, even if it's probably a bad idea.

@jaydenseric

This comment has been minimized.

Copy link

jaydenseric commented Mar 28, 2014

@dantman I tried that, no effect also.

What did work was restructuring everything.

In the end:

font-custom-project-filestructure-working

With:

font_name: icons
no_hash: true
output:
  fonts: ../
  _icons.scss: ../../../styles
templates: [_icons.scss]

Running from the project root:

$ cd fonts/icons/fontcustom
$ fontcustom watch 

Note that running $ fontcustom watch fonts/icons/fontcustom from the project root will not pick up the config file and will set up a standard fontcustom folder in the root.

@ShaggyDude

This comment has been minimized.

Copy link

ShaggyDude commented Oct 3, 2014

can you create a repo with all the default templates set up so that someone can pull it down and tweak the templates?
Very cool project with a very frustrating setup..

@jaydenseric

This comment has been minimized.

Copy link

jaydenseric commented Oct 3, 2014

@ShaggyDude Might do that this weekend. It is already on Github as part of my Barebones repo but it does make sense to maintain the Font Custom Sass setup independently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment