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

bootstrap "scalafmt --diff" fails with FNFE for build.sbt when run from subdir #927

Closed
kitbellew opened this Issue May 9, 2017 · 6 comments

Comments

Projects
None yet
3 participants
@kitbellew

This template is a guideline, not a strict requirement.

  • Version: 0.7.0-RC1
  • Integration: bootstrap CLI
  • Configuration:
style = default
maxColumn = 100
lineEndings = unix
continuationIndent.callSite = 2
continuationIndent.defnSite = 4
continuationIndent.extendSite = 4
align.tokens = []
align.arrowEnumeratorGenerator = false
align.openParenCallSite = false
includeCurlyBraceInSelectChains = true
optIn.annotationNewlines = true
optIn.configStyleArguments = true
optIn.breakChainOnFirstMethodDot = true
newlines.alwaysBeforeTopLevelStatements = false
newlines.alwaysBeforeCurlyBraceLambdaParams = true
newlines.afterCurlyLambda = never
newlines.sometimesBeforeColonInMethodReturnType = false
newlines.penalizeSingleSelectMultiArgList = true
newlines.afterImplicitKWInVerticalMultiline = true
newlines.beforeImplicitKWInVerticalMultiline = true
binPack.literalArgumentLists = true
binPack.parentConstructors = false
runner.optimizer.forceConfigStyleOnOffset = 50
runner.optimizer.forceConfigStyleMinArgCount = 3
rewrite.rules = [ExpandImportSelectors, PreferCurlyFors]
danglingParentheses = true
runner.fatalWarnings = true
verticalMultilineAtDefinitionSite = false

Steps

I ran scalafmt like this:

git clone xxxx/yyy.git
cd yyy # in git top-level dir
mkdir utils
pushd utils
# store scalafmt in a subdirectory
coursier bootstrap com.geirsson:scalafmt-cli_2.11:0.7.0-RC1 --main org.scalafmt.cli.Cli -o scalafmt
popd # back to git top-level dir
vim .scalafmt.conf
pushd spark # go to project subdir
ln -s ../.scalafmt.conf . # this is for Intellij
../utils/scalafmt --diff

Problem

Scalafmt exits with the FileNotFoundException looking for yyy/spark/spark/build.sbt (note "spark/" is mentioned twice).

Expectation

I would like the tool not to fail and find build.sbt in yyy/spark/build.sbt if necessary.

Workaround

I've found that by running scalafmt --diff from the git top-level directory (instead of the project subdirectory), this error is avoided.

Notes

See also..

@olafurpg olafurpg added the help wanted label May 9, 2017

@olafurpg

This comment has been minimized.

Show comment
Hide comment
@olafurpg

olafurpg May 9, 2017

Member

Thank you for reporting! Good catch :)

The culprit line is probably this one here

AbsoluteFile.fromFile(new File(x), workingDirectory)

Instead of using the working directory as base, we should probably use GitOps.rootDir. If someone wants to take a swing at this, a good way to test this change would be here

test("config is read even from nested dir") {

Member

olafurpg commented May 9, 2017

Thank you for reporting! Good catch :)

The culprit line is probably this one here

AbsoluteFile.fromFile(new File(x), workingDirectory)

Instead of using the working directory as base, we should probably use GitOps.rootDir. If someone wants to take a swing at this, a good way to test this change would be here

test("config is read even from nested dir") {

@olafurpg olafurpg added the bug label May 9, 2017

pjrt added a commit to pjrt/scalafmt that referenced this issue May 23, 2017

Revert to lsTree and fix #927
Turns out that `git ls-tree` is more robust that `ls-files`.
Also, fix #927

@olafurpg olafurpg closed this in cb72a48 May 24, 2017

@pjrt

This comment has been minimized.

Show comment
Hide comment
@pjrt

pjrt Jun 2, 2017

Collaborator

This issue wasn't fixed. It is still happening. :(

Collaborator

pjrt commented Jun 2, 2017

This issue wasn't fixed. It is still happening. :(

@pjrt pjrt reopened this Jun 2, 2017

pjrt added a commit to pjrt/scalafmt that referenced this issue Jun 2, 2017

Fix #960 and #927: Oddness with git and non-root
Fixes an issue where git commands would act oddly if `scalafmt` is called
from where NOT at the git root.

pjrt added a commit to pjrt/scalafmt that referenced this issue Jun 2, 2017

Fix #960 and #927: Oddness with git and non-root
Fixes an issue where git commands would act oddly if `scalafmt` is called
from anywhere NOT at the git root.

olafurpg added a commit that referenced this issue Jun 3, 2017

@olafurpg

This comment has been minimized.

Show comment
Hide comment
@olafurpg

olafurpg Jun 17, 2017

Member

I believe this issue got fixed in #961. Can you verify @kitbellew ?

Member

olafurpg commented Jun 17, 2017

I believe this issue got fixed in #961. Can you verify @kitbellew ?

@olafurpg olafurpg added the cli label Jul 9, 2017

@kitbellew

This comment has been minimized.

Show comment
Hide comment
@kitbellew

kitbellew Sep 11, 2017

@olafurpg sorry for a very long delay. this problem seems to have disappeared. (although others have turned up now.)

@olafurpg sorry for a very long delay. this problem seems to have disappeared. (although others have turned up now.)

@olafurpg

This comment has been minimized.

Show comment
Hide comment
@olafurpg

olafurpg Sep 11, 2017

Member

@kitbellew can you elaborate on the other problems? Please open a new ticket.

Member

olafurpg commented Sep 11, 2017

@kitbellew can you elaborate on the other problems? Please open a new ticket.

@olafurpg olafurpg closed this Sep 11, 2017

@kitbellew

This comment has been minimized.

Show comment
Hide comment
@kitbellew

kitbellew Sep 11, 2017

@olafurpg created a couple of issues, hopefully not too many duplicates:

#1040
#1041
#1042

and some feature requests:

#1039
#1043

Thanks for your great tool!

@olafurpg created a couple of issues, hopefully not too many duplicates:

#1040
#1041
#1042

and some feature requests:

#1039
#1043

Thanks for your great tool!

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