Comments (18)
I talked to the author of ptools
, and he told me that this behavior in ptools
is by design. And it's not ptools
who changes this behavior but win32/file
.
from middleman-deploy.
If you can tell me what that if-clause is trying to do generally, maybe I can help you with a better solution.
from middleman-deploy.
@djberg96 Thanks for your help! But I haven't started to look into those logics. Instead, I'm looking at what from ptools
is used in this gem. Seems only File.binary?()
.
from middleman-deploy.
I guess I've found the problem...
The final moment before crash in middleman
is at middleman-core-3.3.2/lib/middleman-core/cli/build.rb:193
:
(@source_dir + @app.images_dir).relative_path_from(@app.root_path)
Here, the @source_dir
comes from middleman-core-3.3.2/lib/middleman-core/application.rb:214
:
def source_dir
File.join(root, config[:source])
end
which is parsed by File.join
.
While the @app.root_path
comes from middleman-core-3.3.2/lib/middleman-core/application.rb:59
:
def self.root
ENV['MM_ROOT'] || Dir.pwd
end
delegate :root, :to => :"self.class"
# Pathname-addressed root
def self.root_path
Pathname(root)
end
which is un-parsed.
Both variables are {Pathname}
.
When executed without win32/file
, both variables were using /
. But when we required win32/file
, the @source_dir
became with \
while the @app.root_path
was still with /
. And the #relative_path_from
of {Pathname}
does not allow comparing paths with different separators.
This is tricky... Because middleman
itself does not using win32/file
. I don't think that we can say it's a bug of middleman
. But at middleman-deploy
side, I don't know how to deal with it.
from middleman-deploy.
I tried to override @source_dir
or @app.root_path
but failed because of this lines:
# middleman-core-3.3.2/lib/middleman-core/cli/build.rb:206
if @build_dir.expand_path.relative_path_from(@source_dir).to_s =~ /\A[.\/]+\Z/
The pathname
lib behave differently in different methods after required win32/file
.
Some methods like +
will convert /
to \
, but #expand_path
always returns path with '/' no matter win32/file
is required or not.
More important, Pathname#relative_path_from
always crash if the path is with '/' when win32/file
is required.
I'll try these possible solutions tomorrow if I have time, but I don't believe any of them will be a good solution, at best a workaround:
- Remove
ptools
fromftp.rb
&sftp.rb
, then find another substitute to provideFile#binary?
- Overrides a part of what
win32/file
has overrided back. - Overrides some methods of ruby's
Pathname
class.
Is there any expert can help?
from middleman-deploy.
What happens if you install and require the pathname2 gem?
from middleman-deploy.
It crashed because pathname2 let Pathname#join()
to return a string instead of a new Pathname.
from middleman-deploy.
There are too many codes in middleman
are using plain string to process paths which conflicts win32/file
...
# e.g.
base_path = path.sub("#{load_path}/", '')
# or
if load_path.end_with?('/images')
from middleman-deploy.
This is something I wouldn't do:
if load_path.end_with?('/images')
Instead:
if File.basename(load_path) == 'images'
Using String#sub to mangle paths is a bad idea in general. With respect, I think maybe some refactoring is in order.
from middleman-deploy.
Hm, maybe I need to updated the pathname2 gem then. Arguably a bug.
from middleman-deploy.
I updated the pathname2 gem at least so that Pathname#join and Pathname#expand_path now return Pathname objects.
from middleman-deploy.
@djberg96 Tried pathname2 =1.7.2
. This time bundler-1.6.2/lib/bundler.rb:192
crashed:
def root
default_gemfile.dirname.expand_path
end
Cause is Pathname#dirname
returns plain string in some case:
require 'pathname'
puts Pathname.new('D:/asdf/qwert').dirname.expand_path
# => D:/asdf
require 'pathname2'
puts Pathname.new('D:/asdf/qwert').dirname.expand_path
# => undefined method `expand_path' for "D:\\asdf":String (NoMethodError)
from middleman-deploy.
Ok, both basename and dirname have been updated to return Pathname objects in 1.7.3.
from middleman-deploy.
Does anything need to happen to middleman deploy so that it picks up these updates?
from middleman-deploy.
I am currently facing the same issue, darn. Did @whitetrefoil solve this somehow eventually? or resolved to use some other gem? Hence, if the problem is all the way inside middleman-core - I believe that we can't get this solved here, or can we?
My setup is: middleman-deploy (0.2.4), middleman (3.3.3) and ptools (1.2.4 universal-mingw32)
from middleman-deploy.
Is this still a problem since I've update pathname2?
from middleman-deploy.
@whitetrefoil Any luck?
from middleman-deploy.
@djberg96 oops... Sorry, I didn't see your previous message. I haven't written ruby for years, and I can't remember details of this issue. I need some time to catch up.
I guess we can close this issue. If there's still problem we can just reopen it.
from middleman-deploy.
Related Issues (20)
- README: 'deploy_method' should be 'deploy' HOT 5
- Local changes would be overwritten by checkout
- CNAME gets blown out with force update HOT 4
- `block in initialize': undefined method `deploy_method=' for #<Middleman::Deploy
- Can't deploy to remote HOT 1
- Deploy build directory to github pages? HOT 7
- Git Force-Push Deploy Pushes Root Instead of Build Dir HOT 18
- undefined method "deploy_method" HOT 7
- Compatibility with Middleman 4.1.7 HOT 4
- Deploy path doesn't work for Git Deploy Method HOT 1
- Rsync: Configured username ignored HOT 4
- Forceful deploy cause long upload times
- deploy.user not being set HOT 1
- Error with Middleman 4.2 and middleman-deploy 1.0 HOT 16
- deploy.deploy_method has changed to method HOT 1
- How to deploy robots.txt file HOT 1
- Ubuntu 18.04 rsync method fails
- Support additional commands during deploy
- Feature Request: support a different trunk branch HOT 1
- Is this gem abandoned? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from middleman-deploy.