Skip to content
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

Default installation doesn't seem to work on macOS #11

Open
jareware opened this issue Mar 6, 2021 · 4 comments
Open

Default installation doesn't seem to work on macOS #11

jareware opened this issue Mar 6, 2021 · 4 comments

Comments

@jareware
Copy link

jareware commented Mar 6, 2021

$ cat .openscad-format
---
BasedOnStyle: Mozilla
ColumnLimit: 80
# SortIncludes: true
IndentWidth: 4
AccessModifierOffset: -4
ContinuationIndentWidth: 4
TabWidth: 4
UseTab: Never
$ npm install openscad-format

+ [email protected]
added 191 packages from 177 contributors and audited 191 packages in 6.211s

4 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities
$ ./node_modules/.bin/openscad-format --version
1.0.0
$ clang-format --version
clang-format version 11.1.0
$ echo 'cube(1);' > test.scad
$ ./node_modules/.bin/openscad-format < test.scad

The above outputs nothing. 🤔

@pixelcmtd
Copy link

just had the same thing happen to me

@n8henrie
Copy link

n8henrie commented May 6, 2022

No luck here either. No output, no error, exit status 0, but doesn't seem to do anything.

@n8henrie
Copy link

n8henrie commented May 6, 2022

@pixelcmtd @jareware it looks like it relies on clang-format for much of the heavy lifting. My code doesn't use any imports, and I already had llvm installed, so clang-format actually worked fine all on its own.

Here's a little bash script I whipped up:

#!/usr/bin/env bash

set -Eeuf -o pipefail
shopt -s inherit_errexit

main() {
  infile=$1
  tmpfile=$(mktemp)
  /opt/homebrew/opt/llvm/bin/clang-format "${infile}" > "${tmpfile}"
  cp "${tmpfile}" "${infile}"
}
main "$@"

@FreeWilly2022
Copy link

FreeWilly2022 commented Jul 1, 2022

I was able to sort of get it to work on my MacBook using the following steps -

Watched the first part of this video titled "What is NPM and why do we need it?"
https://www.youtube.com/watch?v=P3aKRdUyr0s

That video does a good job of explaining what is going on. In summary, node is a JavaScript runtime built on Chrome's V8 JavaScript engine and npm is a program for downloading programs from npm which is a repository for sharing programs. It is annoying that they used the same name for a program and website, but hey its free. Per the video I went to nodejs.org and it showed me a download button for my operating system. This one button downloads both node and npm. Then I found the terminal program in the Applications folder/Utilities folder and checked that both ran by typing: node -v and: npm -v per the video.

After some failed attempts, I figured out that you have to type sudo in front of the npm install command to have admin privileges to actually get it to work somewhat. So, in terminal, type: sudo npm install -g openscad-format

It loaded something like 350 files, and had 3 errors and some files needed "funding". I have no idea how to resolve the errors, and was going to give up. But I tried openscad-format anyway and it seems to work.

I was able to run openscad-format by changing directory (cd) to where I had my file and typing the commands per the directions. It formatted my 800 line program to 1200 lines, but it looks better. In two of the lines that were long it broke up a variable and put commas in the center. I got undefined errors when I ran the preview and was able to easily fix it. I don't think the -j option works because I could not find any templates, so maybe this was related to the errors.

Note that I never created a NPM username or password, and I did not need to go to their website at all to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants