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

~ in polling mode is not triggered by IntelliJ IDEA saving files in macOS #3775

Closed
mechkg opened this Issue Nov 28, 2017 · 11 comments

Comments

Projects
None yet
7 participants
@mechkg

mechkg commented Nov 28, 2017

steps

  1. Create a barebones SBT project, e.g. using new SBT project in IntelliJ IDEA. Add a test source file, e.g.
object Test extends App {
  println ("Hello SBT!")
}
  1. Start SBT and run any command prefixed with ~, e.g.

    ~run

  2. Edit the file in IDEA and save it.

problem

SBT does not detect file changes and does not re-run the command.

expectation

SBT should detect file changes and re-run the command.

notes

Changes made by other editors (e.g. TextMate, nano) do trigger SBT 1.0.4!

SBT 0.13.16 triggers correctly regardless of what program modified the file.

SBT 1.0.4 triggers correctly in nio mode (via -Dsbt.watch.mode=nio) albeit with a delay.

SBT version: 1.0.0 - 1.0.4
macOS version: High Sierra 10.13.1
Java version: 1.8.0_151

@mechkg

This comment has been minimized.

Show comment
Hide comment
@mechkg

mechkg commented Nov 28, 2017

See also sbt/io#86

@dwijnand dwijnand added the Bug label Nov 28, 2017

@dwijnand dwijnand added this to the 1.0.5 milestone Nov 28, 2017

@dwijnand dwijnand self-assigned this Nov 28, 2017

@xerial

This comment has been minimized.

Show comment
Hide comment
@xerial

xerial Nov 29, 2017

Contributor

@mechkg Good catch!

Contributor

xerial commented Nov 29, 2017

@mechkg Good catch!

@dwijnand

This comment has been minimized.

Show comment
Hide comment
@dwijnand

dwijnand Nov 29, 2017

Member

Upstream sbt/io#86

Member

dwijnand commented Nov 29, 2017

Upstream sbt/io#86

dwijnand added a commit to sbt/io that referenced this issue Nov 29, 2017

dwijnand added a commit to dwijnand/sbt-io that referenced this issue Nov 29, 2017

@eatkins

This comment has been minimized.

Show comment
Hide comment
@eatkins

eatkins Nov 30, 2017

Contributor

I referenced this in #3695 but, as a temporary fix, I added an sbt plugin that replaces the WatchService for OSX with one that uses the Apple File System Events API. https://github.com/swoval/MacOSXWatchService

Contributor

eatkins commented Nov 30, 2017

I referenced this in #3695 but, as a temporary fix, I added an sbt plugin that replaces the WatchService for OSX with one that uses the Apple File System Events API. https://github.com/swoval/MacOSXWatchService

eatkins added a commit to eatkins/sbt that referenced this issue Dec 1, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This was both a resource leak and likely was
preventing some updates from being seen.

May be related to sbt#3775, sbt#3695

eatkins added a commit to eatkins/sbt that referenced this issue Dec 1, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This may have prevented some of the file updates
from being seen by the watch service. Moreover, because we lost the
reference to the original WatchService, there was no way to clean it up,
which was a resource leak.

May be related to sbt#3775, sbt#3695

eatkins added a commit to eatkins/sbt that referenced this issue Dec 1, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This may have prevented some of the file updates
from being seen by the watch service. Moreover, because we lost the
reference to the original WatchService, there was no way to clean it up,
which was a resource leak.

May be related to sbt#3775, sbt#3695

eatkins added a commit to eatkins/sbt that referenced this issue Dec 1, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This may have prevented some of the file updates
from being seen by the watch service. Moreover, because we lost the
reference to the original WatchService, there was no way to clean it up,
which was a resource leak.

May be related to sbt#3775, sbt#3695

eatkins added a commit to eatkins/sbt that referenced this issue Dec 3, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This may have prevented some of the file updates
from being seen by the watch service. Moreover, because we lost the
reference to the original WatchService, there was no way to clean it up,
which was a resource leak.

May be related to sbt#3775, sbt#3695

renatocaval added a commit to renatocaval/akka that referenced this issue Dec 4, 2017

Adds sbt-mac-watch-service plugin
This is a temporary fix for sbt/sbt#3775.

The issue only affects developers using Mac and IntelliJ.

renatocaval added a commit to renatocaval/akka that referenced this issue Dec 4, 2017

Adds sbt-mac-watch-service plugin
This is a temporary fix for sbt/sbt#3775.

This issue only affects developers using Mac and IntelliJ.

eatkins added a commit to eatkins/sbt that referenced this issue Dec 7, 2017

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This was both a resource leak and likely was
preventing some updates from being seen.

May be related to sbt#3775, sbt#3695

@eed3si9n eed3si9n removed the in progress label Dec 13, 2017

@dwijnand dwijnand modified the milestones: 1.1.1, 1.1.0 Dec 13, 2017

@dwijnand

This comment has been minimized.

Show comment
Hide comment
@dwijnand

dwijnand Dec 13, 2017

Member

Re-opening to track sbt/io needs releasing for inclusion in 1.1.0-RC2.

Member

dwijnand commented Dec 13, 2017

Re-opening to track sbt/io needs releasing for inclusion in 1.1.0-RC2.

@dwijnand dwijnand reopened this Dec 13, 2017

@OlegYch

This comment has been minimized.

Show comment
Hide comment
@OlegYch

OlegYch Dec 13, 2017

Contributor

@dwijnand this seems to be specific to IDEA
happens to me on windows, with sbt 1.0.0-1.0.4, with both polling and io, doesn't happen if i eg edit the file with notepad or use IO.touch

Contributor

OlegYch commented Dec 13, 2017

@dwijnand this seems to be specific to IDEA
happens to me on windows, with sbt 1.0.0-1.0.4, with both polling and io, doesn't happen if i eg edit the file with notepad or use IO.touch

@OlegYch

This comment has been minimized.

Show comment
Hide comment
@OlegYch

OlegYch Dec 13, 2017

Contributor

the only difference i can see is that when IDEA saves file - directory last modified time is updated, but not when i use touch

Contributor

OlegYch commented Dec 13, 2017

the only difference i can see is that when IDEA saves file - directory last modified time is updated, but not when i use touch

@eed3si9n

This comment has been minimized.

Show comment
Hide comment
@eed3si9n

eed3si9n Dec 16, 2017

Member

New io with the fix was merged in #3816.
If the issue persists with 1.1.0-RC2, then we will reopen this case.

Member

eed3si9n commented Dec 16, 2017

New io with the fix was merged in #3816.
If the issue persists with 1.1.0-RC2, then we will reopen this case.

@eed3si9n eed3si9n closed this Dec 16, 2017

@dwijnand

This comment has been minimized.

Show comment
Hide comment
@dwijnand

dwijnand Dec 16, 2017

Member

This issue was about macOS though, where it's using polling. If there are issues with NIO and/or IntelliJ, on Windows, they should be reported.

Member

dwijnand commented Dec 16, 2017

This issue was about macOS though, where it's using polling. If there are issues with NIO and/or IntelliJ, on Windows, they should be reported.

@hedefalk

This comment has been minimized.

Show comment
Hide comment
@hedefalk

hedefalk Dec 20, 2017

I struck this problem with IDEA saves not triggering my ~compile. So I found this and upgraded to latest RC, but now I instead get this issue that it doesn't seem to resolve a softlink for a git-hook:

sbt:root> ~compile
Exception in thread "Thread-11" java.io.FileNotFoundException: No such file or directory: /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit
	at sbt.internal.io.MilliPosixBase.checkedIO(Milli.scala:97)
	at sbt.internal.io.MacMilli$.getModifiedTimeNative(Milli.scala:248)
	at sbt.internal.io.MacMilli$.getModifiedTimeNative(Milli.scala:239)
	at sbt.internal.io.MilliNative.getModifiedTime(Milli.scala:66)
	at sbt.internal.io.Milli$.getModifiedTime(Milli.scala:357)
	at sbt.io.IO$.getModifiedTime(IO.scala:1163)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$3(PollingWatchService.scala:96)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$2(PollingWatchService.scala:96)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$2$adapted(PollingWatchService.scala:93)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at sbt.io.PollingWatchService$PollingThread.getFileTimes(PollingWatchService.scala:93)
	at sbt.io.PollingWatchService$PollingThread.populateEvents(PollingWatchService.scala:110)
	at sbt.io.PollingWatchService$PollingThread.run(PollingWatchService.scala:86)

It is however there as a softlink:

~/d/p/a/.git ❯❯❯ ll /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit
lrwxr-xr-x 1 viktor staff 23B Mar 7 2017 /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit@ -> ../../bin/pre-commit.sh

Could this be related to the fix? Dunno why it's trying to grab that file, I have the sbt git plugin sure, but…

hedefalk commented Dec 20, 2017

I struck this problem with IDEA saves not triggering my ~compile. So I found this and upgraded to latest RC, but now I instead get this issue that it doesn't seem to resolve a softlink for a git-hook:

sbt:root> ~compile
Exception in thread "Thread-11" java.io.FileNotFoundException: No such file or directory: /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit
	at sbt.internal.io.MilliPosixBase.checkedIO(Milli.scala:97)
	at sbt.internal.io.MacMilli$.getModifiedTimeNative(Milli.scala:248)
	at sbt.internal.io.MacMilli$.getModifiedTimeNative(Milli.scala:239)
	at sbt.internal.io.MilliNative.getModifiedTime(Milli.scala:66)
	at sbt.internal.io.Milli$.getModifiedTime(Milli.scala:357)
	at sbt.io.IO$.getModifiedTime(IO.scala:1163)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$3(PollingWatchService.scala:96)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$2(PollingWatchService.scala:96)
	at sbt.io.PollingWatchService$PollingThread.$anonfun$getFileTimes$2$adapted(PollingWatchService.scala:93)
	at scala.collection.mutable.ResizableArray.foreach(ResizableArray.scala:59)
	at scala.collection.mutable.ResizableArray.foreach$(ResizableArray.scala:52)
	at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
	at sbt.io.PollingWatchService$PollingThread.getFileTimes(PollingWatchService.scala:93)
	at sbt.io.PollingWatchService$PollingThread.populateEvents(PollingWatchService.scala:110)
	at sbt.io.PollingWatchService$PollingThread.run(PollingWatchService.scala:86)

It is however there as a softlink:

~/d/p/a/.git ❯❯❯ ll /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit
lrwxr-xr-x 1 viktor staff 23B Mar 7 2017 /Users/viktor/dev/projects/[project]/.git/hooks/pre-commit@ -> ../../bin/pre-commit.sh

Could this be related to the fix? Dunno why it's trying to grab that file, I have the sbt git plugin sure, but…

@dwijnand

This comment has been minimized.

Show comment
Hide comment
@dwijnand

dwijnand Dec 20, 2017

Member

That's #3820.

Member

dwijnand commented Dec 20, 2017

That's #3820.

eed3si9n added a commit to eed3si9n/sbt that referenced this issue Mar 9, 2018

Cache watch service
I noticed that my custom WatchService was never cleaned up by sbt and
realized that after every build we were making a new WatchService. At
the same time, we were reusing the WatchState from the previous run,
which was using the original WatchService. This was particularly
problematic because it prevented us from registering any paths with the
new watch service. This may have prevented some of the file updates
from being seen by the watch service. Moreover, because we lost the
reference to the original WatchService, there was no way to clean it up,
which was a resource leak.

May be related to sbt#3775, sbt#3695
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment