Scotland is a devolved government, effectively a separate country within the UK. And, as with the UK's overseas colonies, there's a longstanding constitutional convention that Westminster doesn't legislate for Scotland without Scotland's consent. But Brexit means reallocating EU powers within the UK, and that means legislating for Scotland, if only to determine where they go. But the Scottish parliament doesn't like the deal being offered (under which they merely get "consulted"), and so have effectively vetoed it in an effort to get a better one:
The Scottish parliament has voted against Theresa May’s Brexit legislation by a large margin, putting the UK on the brink of a major constitutional dispute.
Holyrood rejected the UK government’s EU withdrawal bill by 93 votes to 30 on Tuesday after Labour, the Liberal Democrats and Scottish Greens backed Nicola Sturgeon’s decision to oppose proposals on post-Brexit power sharing set out in clause 11 of the bill.
The vote is not legally binding but it will force the prime minister to make a high-risk decision to impose those power-sharing plans on Scotland or make further concessions to the Scottish government to avoid a crisis.
Westminster purporting to legislate for Scotland without their consent and in defiance of constitutional convention would undoubtedly be legal (because they would say that it would be), but equally undoubtedly unconstitutional. Of course, Scotland has a solution if they don't like England's Brexit deal: leave. And with Scottish voters voting overwhelmingly to stay in the EU, its an option they should take.